如何为以下查询创建codeigniter活动记录?

时间:2016-10-19 09:22:56

标签: php mysql codeigniter-3

如何为以下查询创建codeigniter活动记录?

$query = $this->db->query("SELECT * FROM `student`JOIN `pay_log` ON 
`student`.`student_id` = `pay_log`.`student_id` WHERE (`activity` LIKE '%yr%' 
OR `activity` LIKE '%yr1%') AND `class_id` = 'cl123' AND `student`.`status` = 'active'");

1 个答案:

答案 0 :(得分:1)

试试这个

      $query = $this->db
              ->select()
              ->from( 'student as s' )
              ->join( 'pay_log as p', 's.student_id = p.student_id' )
              ->where( 'activity LIKE "%yr%" OR activity LIKE "%yr1%"', FALSE )
              ->where( 'class_id', 'cl123' )
              ->where( 's.status', 'active' )
              ->get();