[eluser]CI_Newb[/eluser]
Searching for stn: 4035903698 (which is confirmed in the database table)
Model
Code:
$start_date = $this->input->post('startDate');
$end_date = $this->input->post('endDate');
$nsAgent = $this->session->userdata('username');
$manager_id = $this->input->post('manager_id');
$stn = $this->input->post('stn');
$notes = $this->input->post('notes');
$resolution = $this->input->post('resolution');
$dateRange = "tdate BETWEEN '%$start_date%' and '%$end_date%'";
$this->db->where($dateRange, NULL);
$this->db->where('username', $nsAgent);
$this->db->like('manager_id', $manager_id);
$this->db->like('stn', $stn);
$this->db->like('notes', $notes);
$this->db->like('resolution', $resolution);
$data = $this->db->get('NS_data');
if($data->num_rows() > 0) {
return $data;
}
When I echo query, I get
Code:
SELECT * FROM (`NS_data`) WHERE `tdate` BETWEEN '%%' and '%%' AND `username` = 't815138' AND `manager_id` LIKE '%%' AND `stn` LIKE '@35903698%' AND `notes` LIKE '%%' AND `resolution` LIKE '%%'
Which doesn't produce a result.
If I select a startDate and endDate, it shows up.
Code:
SELECT * FROM (`NS_data`) WHERE `tdate` BETWEEN ' 10-10-01%' and ' 10-10-06%' AND `username` = 't815138' AND `manager_id` LIKE '%%' AND `stn` LIKE '@35903698%' AND `notes` LIKE '%%' AND `resolution` LIKE '%%'
If I just comment out
Code:
//$this->db->where($dateRange, NULL);
It works no problems.
What's going on?