如何在CodeIgniter中编写查询,如下所示? [关闭]

SELECT * FROM abc WHERE (abc LIKE '%value%' OR def LIKE '%value%') AND ghij NOT IN ('1', '2')

You can convert this query:

SELECT * FROM abc 
WHERE (abc LIKE '%value%' OR def LIKE '%value%') AND ghij NOT IN ('1', '2')

Into Codeignitor as:

$this->db->select();
$this->db->from('abc'); // FROM table
$this->db->like('abc', '%value%', 'both');  //WHERE LIKE
$this->db->or_like('def', '%value%');  //WHERE OR LIKE
$this->db->where_not_in('ghij', array('1', '2')); //WHERE NOT IN
$query = $this->db->get(); 
$result = $query->result_array(); // RESULT IN ARRAY

print_r($result);