Php CI-ActiveRecord中的组合条件

Php CI-ActiveRecord中的组合条件,php,mysql,codeigniter,activerecord,Php,Mysql,Codeigniter,Activerecord,我想做一个sql查询,比如 select * where x = 10 and (y=12 or h=15) 如何在CI ActiveRecord格式中实现这一点?试试看 $sql = "SELECT * FROM TABLE_NAME WHERE x = 10 AND (y = 12 OR h = 15)"; $result = $this->db->query($sql); 或者 $this->db->select('*'); $this->db->f

我想做一个sql查询,比如

select * where x = 10 and (y=12 or h=15)
如何在CI ActiveRecord格式中实现这一点?

试试看

$sql = "SELECT * FROM TABLE_NAME WHERE x = 10 AND (y = 12 OR h = 15)";
$result = $this->db->query($sql);
或者

$this->db->select('*');
$this->db->from('TABLE_NAME');
$this->db->where('x',10);
$this->db->AND('y',12);
$this->db->or_where('h',15);
$query = $this->db->get();
参见参考文献

$where="x = 10 and (y=12 or h=15)";
$this->db->select('*');
$this->db->from('mytable');
$this->db->where($where);
$query = $this->db->get();

Octaivian需要ActiveRecord格式,请参阅