Welcome Guest, Not a member yet? Register   Sign In
Active Record Clear Parameters
#1

[eluser]USCTrojans[/eluser]
Hello,

I have a logged in model that is called in my parent function to check for users being logged in. When I call another function in that controller, and call a model it "inherits the search parameters from the parent which is searching a different table. Does anyone know how to clear the query?

I'm getting an error that looks like this

Code:
A Database Error Occurred

Error Number: 1066

Not unique table/alias: 'sessions'

SELECT `network` FROM (`sessions`, `sessions`, `sessions`, `morehousej09_gmail_com`) WHERE `session_id` = '3022ad6c14c0508885196a7d9783424b' AND `session_id` = '3022ad6c14c0508885196a7d9783424b' AND `session_id` = '3022ad6c14c0508885196a7d9783424b' AND `username` = '[email protected]'

Filename: /Users/MorehouseJ09/Documents/Web Development/Danzan Capital/Sprint 1/modules/mainsite/models/user_information_retrieve.php

Line Number: 23

But in the model that is called , only the "morehouse_j09_gmail_com" table should be searched. How do I clear the results from that parent function which searches my "sessions" table in sql?

Thanks
#2

[eluser]aquary[/eluser]
I think you put something wrong in you script.....Post your code, then we could help.
#3

[eluser]USCTrojans[/eluser]
I think it had to do with not "getting" the result. I queried some data and just tested to see if it came back true. I think that somehow cached the query and until I realized I needed to get() the data, it didn't work. Here's my code:

Code:
$query = $this->db->from('sessions')->where('session_id', $browser_session['session_id']);
  $this->db->get();

so without the second line it broke my other function. I had just been using an if(!query) to test if the session was legitimate.

Thanks
#4

[eluser]aquary[/eluser]
Maybe you have use $this->db->from('sessions') somewhere else, before the line itself, without using it. Better checking where did they come from since you might encounter some error like this again.

Btw, I always use $this->db->get('table_name') which help avoiding these kind of errors.




Theme © iAndrew 2016 - Forum software by © MyBB