我想知道Active Record中是否有任何方法可以创建一个嵌套WHERE
案例的查询,如:
SELECT * FROM Users WHERE FirstName = 'John' AND (LastName = 'Smith' OR LastName = 'Jones');
答案 0 :(得分:2)
是的,您可以使用where()
功能
$this->db->select('*');
$this->db->from('Users ');
$this->db->where("FirstName = 'John'");
$this->db->where(" (LastName = 'Smith' OR LastName = 'Jones') ");
$result=$this->db->get();
答案 1 :(得分:0)
您需要传递WHERE子句才能执行此操作。
$this->db->where("FirstName = 'John' AND (LastName = 'Smith' OR LastName = 'Jones')");