【发布时间】:2016-05-18 23:51:24
【问题描述】:
我不知道这个 sql 查询的 codeigniter db translate
select * from table
where a=1 and (b=1 or c=1 or d=1)
$this->db->where $this->db->or_where ?!?!
有人帮我吗? 多谢 最好的问候
【问题讨论】:
标签: php mysql sql codeigniter where
我不知道这个 sql 查询的 codeigniter db translate
select * from table
where a=1 and (b=1 or c=1 or d=1)
$this->db->where $this->db->or_where ?!?!
有人帮我吗? 多谢 最好的问候
【问题讨论】:
标签: php mysql sql codeigniter where
我认为这是您要查找的查询。
$query = $this->db->select("*")
->from("table")
->where("a", 1)
->group_start()
->where("B", 1)
->or_where('c', 1)
->group_end()
->get()
->result_array();
var_dump($query);
【讨论】:
如果您使用doc
你可以看到,如果你使用 or_where 你会做这样的查询
$this->db->where('name !=', $name);
$this->db->or_where('id >', $id);
// Produces: WHERE name != 'Joe' OR id > 50
【讨论】:
使用此代码。
$this->db->select('*');
$this->db->where('a', 1);
$this->db->or_where('b', 1);
$this->db->or_where('c', 1);
$this->db->or_where('d', 1);
【讨论】: