在codignitor中不工作



我试图得到行,其中hospital_id = 802和多个or_likes,但我的查询是跳过的,其中hospital_id = 802,但做过滤或很好,在查询出错,提前感谢

这是我的查询

SELECT * FROM (`patient`) WHERE `hospital_id` = '802' AND `name` LIKE '%fn%' OR `phone` LIKE '%fn%' OR `nic` LIKE '%fn%' OR `passport` LIKE '%fn%' OR `ticket` LIKE '%fn%' ORDER BY `id` DESC

写在CI

$value = 'fn';
$this->db->or_like('name',$value);
$this->db->or_like('phone',$value);
$this->db->or_like('nic',$value);
$this->db->or_like('passport',$value);
$this->db->or_like('ticket',$value);
$rows=$this->db->where('hospital_id',802)->order_by("id", "DESC")->get('patient')->result();

谁能帮我在Codeigniter风格?

必须使用group start和group end

$this->db->group_start();
$this->db->or_like('name',$value);
$this->db->or_like('phone',$value);
$this->db->or_like('nic',$value);
$this->db->or_like('passport',$value);
$this->db->or_like('ticket',$value);
$this->db->group_end();
$rows=$this->db->where('hospital_id',802)->order_by("id", "DESC")->get('patient')->result();

相关内容

  • 没有找到相关文章

最新更新