如何在codeigniter中连接表时使用or_like

时间:2014-04-25 10:42:14

标签: php codeigniter

这是我的代码,它给了我错误的结果。任何人都能说出正确的解决方案

$this->db->select('tbl_member.*,tbl_country.country_name,tbl_city.city_name');
    $this->db->like('tbl_member.first_name',$_GET['keyword']);
    $this->db->or_like('tbl_member.last_name',$_GET['keyword']);
    $this->db->where('tbl_member.status','Active');
    $this->db->where('tbl_member.approve_status','Active');
    $this->db->where('tbl_member.account_close_by_member','No');
    $this->db->where('tbl_member.account_delete_by_member','No');
    $this->db->order_by('tbl_member.membership_type','Desc');
    $this->db->order_by('tbl_member.membership_expire','Desc');


    $where="( tbl_member.member_type='Independent' || tbl_member.member_type='Agency-Profile')";
    $this->db->where($where);
    $this->db->or_like('tbl_country.country_name',$_GET['keyword']);
    $this->db->or_like('tbl_city.city_name',$_GET['keyword']);
    $this->db->join('tbl_country','tbl_country.ct_id=tbl_member.country_id');
    $this->db->join('tbl_city','tbl_city.c_id=tbl_member.city');
    $query=$this->db->get($this->tablename);
    $record=$query->result();

0 个答案:

没有答案