• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Active Record not putting the FROM clause into its SQL

#1
[eluser]SP1966[/eluser]
Trying to use the ion_auth library and I'm getting this error upon trying to login:


Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `0` = '[email protected]' LIMIT 1' at line 2

SELECT `username`, `email`, `id`, `password`, `active`, `last_login` WHERE `0` = '[email protected]' LIMIT 1

Here is the Active Record code from ion_auth that is throwing the error:

$query = $this->db->select($this->identity_column . ', username, email, id, password, active, last_login')
->where($this->identity_column, $this->db->escape_str($identity))
->limit(1)
->get($this->tables['users']);


Any idea what I've messed up for this to be happening?

#2
[eluser]Aken[/eluser]
Edit - nevermind, that advice won't matter. Will look again.

Also FYI, when using active record, you don't need to escape values first, AR will do it for you (unless you specifically tell it not to, which you can in a few different methods). In your case, it's not necessary.

#3
[eluser]SP1966[/eluser]
The code is from the ion_auth library, so I've just left it as they wrote it. As for the identity_column I've taken this code and hard coded the correct data into it and run it only to get the same error. Near as I can tell the error is somewhere in Active Record.

I appreciate your having taken the time to reply!

#4
[eluser]SP1966[/eluser]
Alright, I managed to find out what I was doing wrong. The issue was caused by my setting the ion_auth library to autoload which is apparently not what you want to do as its loaded by ion_auth itself as needed. Removed ion_auth from autoload and its working as advertised, which is to say excellent!

Just thought I would add the above in case someone else makes the same mistake and searches for the answer here.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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