• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Session database errors and query builder chaining

#1
I am having an issue on production server after upgrading to CI3. Additional conditions are being added to a session database query by the query builder. The two where clauses in bold are from a simple select query in an normal CI model, and I am not sure why they are being applied to an update query within the CI_Session_database_driver class. My suspicion is that because these session handler functions are registered using PHPs session_set_save_handler that they have access to the CI->db object that is concurrent with other running processes. Any thoughts on resolving this?

A Database Error Occurred
Error Number: 1054
Unknown column 'ur.user_id' in 'where clause'

UPDATE `ci_sessions` SET `timestamp` = 1429568240, `data` = '__ci_last_regenerate|i:1429564536;'
WHERE `ur`.`user_id` = '1'
AND `r`.`active` = 1

AND `id` = 'efe35de70aeeab890cb68562d8058cad6e48d52b'

Filename: libraries/Session/drivers/Session_database_driver.php
Line Number: 243
Reply

#2
My suspicion would be that you are using query caching and the session is being updated while the cache is enabled, but there's not much I can do to help without seeing the code for the model.
Reply

#3
Thanks for your help. Query caching is definitely not enabled anywhere (either in config or manually using the cache_on() function) also, the session database driver would be throwing an error:

PHP Code:
elseif ($this->_db->cache_on)
{
throw new 
Exception('Configured database connection has cache enabled. Aborting.'); 

The model itself is utterly boring, the function in question (which is the only function in the codebase to have these specific where clauses):

PHP Code:
public function get_user_roles($user_id) {
 
       $this->db->select('r.role_id, r.role_name, r.permissions')
 
                ->from('user_role_tbl as ur')
 
                ->join('role_tbl as r''ur.role_id = r.role_id')
 
                ->where('ur.user_id'$user_id)
 
                ->where('r.active'1);

 
       $res $this->db->get();
 
       
        if 
($res->num_rows() == 0) {
 
           return array();
 
       }
 
       
        $data 
= array();
 
       
        foreach
($res->result() as $row) {
 
           ...return the data in array, etc... 

If you can see any issue here please let me know...
Reply

#4
Where is the session being used?
Reply

#5
Hi all,

Experiencing the same issue.

Brand new installation of CI 3 from download. Enabled autoload session. Setup database for session. Error as above any thoughts on this would be appreciated.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.