<?php

class Apidriver_model extends CI_Model
{
    function __consturct()
    {
        parent::__construct();
        
    }
    
    function is_registered1($phone_no)
    {
        //$mob=$_COOKIE['Mobile'];

        $sql = "SELECT `mobile_no` FROM `tbl_driver` WHERE `mobile_no`= '$phone_no'";
        $que1 = $this->db->query($sql);
        $output = $que1->num_rows();
        if ($output == 1) {
            return true;
        } else {
            return false;
        }
    }
    
    function activeuser($phone_no)
    {
        //$mob=$_COOKIE['Mobile'];

        $sql = "SELECT * FROM `tbl_driver` WHERE `mobile_no`= '$phone_no'";
        $que1 = $this->db->query($sql);
        return $que1->row();
    }
    
     function set_f_token_app($user_id, $token)
    {
        $this->db->where('driver_id', $user_id);
        $this->db->update('tbl_driver', ['f_token_app' => $token]);
    }
    
      public function Execute($q, $w = [])
    {
        $query = $this->db->query($q, $w);
        if ($query) {
            return $query;
        } else {
            return false;
        }
    }
    
    
     public function get_api_url() {
        $query = $this->db->get('sms_api_config', 1);
        return $query->row()->api_url;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    public function Insert($table, $f)
    {
        $query = $this->db->insert($table, $f);
        if ($query) {
            $insert_id = $this->db->insert_id();

            return $insert_id;
        } else {
            return false;
        }
    }
    
     function verifyotp($user_id)
    {
        $this->db->select('*,mobile_otp.otp as otp');
        $this->db->from('mobile_otp');
        $this->db->join('tbl_driver', 'tbl_driver.driver_id=mobile_otp.user_id', 'left');
        $this->db->where('mobile_otp.user_id', $user_id);
        $query = $this->db->get();
        return $query->row_array();
    }
    
    
     function is_registered($mobilewithcode, $email)
    {
        $sql = "SELECT * FROM `tbl_driver` WHERE (`mobile_no`= '$mobilewithcode')  OR (`email`= '$email')";
        $que1 = $this->db->query($sql);
        $output = $que1->num_rows();
        return $output;
        
    }  
    function is_registeredmobail($mobilewithcode)
    {
        $sql = "SELECT * FROM `tbl_driver` WHERE `mobile_no`= '$mobilewithcode'";
        $que1 = $this->db->query($sql);
        $output = $que1->num_rows();
        return $output;
        
    }
     function is_registeredemail($email)
    {
        $sql = "SELECT * FROM `tbl_driver` WHERE `email`= '$email'";
        $que1 = $this->db->query($sql);
        $output = $que1->num_rows();
        return $output;
        
    }
    
    public function update_data($table, $field, $id, $data)
    {
        $this->db->where($field, $id);
        return $this->db->update($table, $data);
    }
    

    
}    