将我的sql查询转换为活动记录查询codeigniter

时间:2015-02-16 07:54:26

标签: codeigniter

SELECT * FROM cdr WHERE (Circle LIKE '%D%' OR CLI LIKE '%D%' OR Operator LIKE '%D%') AND Dept = 'Sale'

我只想要它像$ this-> db->喜欢('Circle','%D%')和部门'和'。

1 个答案:

答案 0 :(得分:1)

您应该阅读codeigniter文档,这很简单:

$this->db->where("(Circle LIKE '%D%' OR CLI LIKE '%D%' OR Operator LIKE '%D%')")
         ->where("dept", "Sale");
$query = $this->db->get("cdr"); 

http://www.codeigniter.com/user_guide/database/active_record.html