<?php

class Login_model extends CI_Model
{
    function __consturct()
    {
        parent::__construct();
    }

    
    public function select_column_where($columns, $table_name, $condition) {
    return $this->db->select($columns)->where($condition)->get($table_name)->result_array();
    }
    
    public function insert($table_name, $data) {       
        return $this->db->insert($table_name, $data);
    }
    public function select_column($columns, $table_name) {
        return $this->db->select($columns)->get($table_name)->result_array();
    }
    public function query($query) {
        return $this->db->query($query)->result_array();
    }
   
    public function Update($table, $f, $w = 0)
    {
        if ($w != 0) {
            $this->db->where($w);
        }
        $query = $this->db->update($table, $f);
        if ($query) {
            return true;
        } else {
            return false;
        }
    }
   
   
   
   
   
   
   
   public function Select($Table, $Fields = '*', $Where = 1 , $order_by = '')
    {
        /*
         *  Select Fields
         */
        if ($Fields != '*') {
            $this->db->select($Fields);
        }
        /*
         *  IF Found Any Condition
         */
        if ($Where != 1) {
            $this->db->where($Where);
        }
        if (!empty($order_by)) {
        $this->db->order_by($order_by, "DESC");
        }
        /*
         * Select Table
         */
        $query = $this->db->get($Table);

        /*
         * Fetch Records
         */

        return $query->result();
    }
    
     function is_registered1($phone)
    {
        //$mob=$_COOKIE['Mobile'];

        $sql = "SELECT * FROM `tbl_driver` WHERE `mobile_no`= '$phone'";
        $que1 = $this->db->query($sql);
        $output = $que1->num_rows();
        if ($output != 0) {
                return true;
            } else {
                return false;
            }
    } 
    
    /*
     * Direct Query Execution
     */
    public function Execute($q, $w = array())
    {
        $query = $this->db->query($q, $w);
        if ($query) {
            return $query;
        } else {
            return false;
        }
    }
   
     
     function emailcheckdeliv($email_id)
    {
        //$mob=$_COOKIE['Mobile'];

            $sql = "SELECT * FROM `tbl_driver` WHERE `email`= '$email_id'";
            $que1 = $this->db->query($sql);
            $output = $que1->num_rows();
        if ($output != 0) {
                return true;
            } else {
                return false;
            }
        
    }
        public function update_data($table,$field,$id,$data)
    {
        $this->db->where($field, $id);
        return $this->db->update($table, $data);
    }
    
    public function get_main_banner($user)
    {
        $this->db->select('*');
        $this->db->from('main_banner');
        $this->db->where('created_by', $user);
        $this->db->order_by('date', 'desc');
        $query = $this->db->get();
        return $query->result();
    }
    
     
        public function updateData($tablename, $data, $where)
    {
        $query = $this->db->update($tablename,$data,$where);
        return $query;
    }
    public function deleteData($tablename,$where)
    {
        $query = $this->db->delete($tablename,$where);
        return $query;
    }
    
    
    
}
