CodeIgniter Forums
Sessions not working properly with database where clause - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Sessions not working properly with database where clause (/showthread.php?tid=20065)



Sessions not working properly with database where clause - El Forum - 06-26-2009

[eluser]lennierb5[/eluser]
So I have a filter / search function that checks if post data exists and then adds a $this->db->where clause and then eventually executes the query at the end.

I also want to set session data but what happens is when I set session data AFTER a $this->db->where it tries to include that in the session update to the database.

Example:

Code:
if ($this->input->post('accountnumfilterentry')) {
        $this->db->where('job_data.account_num', $this->input->post('accountnumfilterentry'));
        $this->session->set_userdata('accountnumfilterentry', $this->input->post('accountnumfilterentry'));
        }

Will produce the error:

Code:
A Database Error Occurred

Error Number: 1109

Unknown table 'job_data' in where clause

UPDATE `ci_sessions` SET `last_activity` = '1246042513'

...

WHERE `job_data`.`account_num` = 'ACCOUNTNUMBER' AND `session_id` = '64409e296c1088b68bb7ca555d7ecb4f'

If you put it before the where clause it processes fine but then gets hung up in the next set of IF statements if is more than one filtered item.