Welcome Guest, Not a member yet? Register   Sign In
mysql forbidden field name in WHERE clause ?
#8

[eluser]symbol.software[/eluser]
[quote author="BrianDHall" date="1253311830"]Try executing your SQL string 'manually', so as to see if CI is somehow eating the query or if MySQL is the one complaining.[/quote]

Brian,

After i tested in so many ways here is the result:

if i place this line of code inside my controller the query is running without problems.

Code:
$query = $this->db->get_where('users', array("username"=>"jon", "password"=>"mypassword"));

But if I place the same line of code inside a model class it gives me the following error:

Code:
A Database Error Occurred

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 'password` = 'mypassword'' at line 3

SELECT * FROM (`users`) WHERE ` = 'jon' AND `password` = 'mypassword'

So it is a matter of how CI is interpreting models and controls. If mysql was the one eating my query then why it works without a problem when I run the query from my controller code?


Messages In This Thread
mysql forbidden field name in WHERE clause ? - by El Forum - 09-18-2009, 07:07 AM
mysql forbidden field name in WHERE clause ? - by El Forum - 09-18-2009, 08:07 AM
mysql forbidden field name in WHERE clause ? - by El Forum - 09-18-2009, 08:26 AM
mysql forbidden field name in WHERE clause ? - by El Forum - 09-18-2009, 09:07 AM
mysql forbidden field name in WHERE clause ? - by El Forum - 09-18-2009, 09:08 AM
mysql forbidden field name in WHERE clause ? - by El Forum - 09-18-2009, 09:31 AM
mysql forbidden field name in WHERE clause ? - by El Forum - 09-18-2009, 11:10 AM
mysql forbidden field name in WHERE clause ? - by El Forum - 09-18-2009, 11:16 AM
mysql forbidden field name in WHERE clause ? - by El Forum - 09-18-2009, 12:13 PM
mysql forbidden field name in WHERE clause ? - by El Forum - 09-18-2009, 12:38 PM



Theme © iAndrew 2016 - Forum software by © MyBB