这里有两个条件,$ data& $ data1是不同的。
function f_report_by_year($data, $data1){
$this->db->join('student', 'student.student_id = pay_log.student_id', 'left');
$this->db->where('pay_log.timedate >=', $data.'-04-01');
$this->db->where('pay_log.timedate <=', $data1.'-03-31');
$this->db->or_like('pay_log.activity', 'MDF', 'before');
$this->db->or_like('pay_log.activity', 'MEF', 'before');
$this->db->or_like('pay_log.activity', 'MDD', 'before');
$q = $this->db->get('pay_log');
return $q->result_array();
}
答案 0 :(得分:1)
您可以使用= =&gt;
$sql = "SELECT * FROM some_table WHERE id IN ? AND status = ? AND author = ?";
$this->db->query($sql, array(array(3, 6), 'live', 'Rick'));
答案 1 :(得分:1)
试试这个or_group_start()
https://www.codeigniter.com/userguide3/database/query_builder.html#query-grouping
$this->db->group_start();
$this->db->where('pay_log.timedate >=', $data.'-04-01');
$this->db->where('pay_log.timedate <=', $data1.'-03-31');
$this->db->group_end();
$this->db->group_start();
$this->db->or_like('pay_log.activity', 'MDF', 'before');
$this->db->or_like('pay_log.activity', 'MEF', 'before');
$this->db->or_like('pay_log.activity', 'MDD', 'before');
$this->db->group_end();