CodeIgniter Forums
strange ci_sessions error when attempting to query user table - 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: strange ci_sessions error when attempting to query user table (/showthread.php?tid=21521)



strange ci_sessions error when attempting to query user table - El Forum - 08-12-2009

[eluser]wizzer[/eluser]
Code:
function _getDocumentCap()
{
            $id = $this->session->userdata('UserID');
            $query = $this->db->get('user');
            $this->db->where('UserID',$id);
            foreach ($query->result_array() as $row)
            {
                $doc = $row['NoOfUserDocs'];
            }
            return $doc;
}


Quote:A Database Error Occurred
Error Number: 1054

Unknown column 'UserID' in 'where clause'

UPDATE `ci_sessions` SET `last_activity` = '1250080844', `user_data` = 'a:13:{s:8:\"username\";s:15:\"user


I have no clue what is going on here. Any help would be appreciated


strange ci_sessions error when attempting to query user table - El Forum - 08-12-2009

[eluser]pistolPete[/eluser]
Quote:Unknown column ‘UserID’ in ‘where clause’

The error message tells you that there is no column named "UserID" in your table.
Userdata is saved in a serialized array in the the column "user_data", so you can't use the SQL WHERE.

What exactly do you want to achieve?


strange ci_sessions error when attempting to query user table - El Forum - 08-12-2009

[eluser]wizzer[/eluser]
Thanks for the reply. I have now changed the way i am writing the query.

i was trying to return some data from the users table, but I was unsure why it was giving me an error about ci_sessions; the UserID field is present.

I dont fully understand the way ci works so i will do some more learning.

All sorted anyway :-)