H
H
Hello America2016-09-05 12:17:56
PHP
Hello America, 2016-09-05 12:17:56

The Joomla JFactory::getDbo() class. An incomprehensible error in the SQL query when reading the table, but where?

It seems to be a simple request and very simple

$db = JFactory::getDbo();
$db->setQuery( "SELECT * FROM tur_userxtd_profiles WHERE user_id='622' AND key ='BASIC_AVATAR'");

but it throws an error:
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 'key ='BASIC_AVATAR'' at line 1 SQL=SELECT * FROM #__userxtd_profiles 
WHERE user_id='622' AND key ='BASIC_AVATAR'

Below is the table itself It is
cd71b28d2bda47d9877fca3b9534edca.png
possible that I am stupid on the elementary, but? apparently, he didn’t get enough sleep (
I ran the same SQL in the console and bam, the same error. Why do I have the wrong query?
f014f54e16134445a0c548075a8cec84.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2016-09-05
@websofter

try to escape key

$db->setQuery( "SELECT * FROM tur_userxtd_profiles WHERE user_id='622' AND `key` ='BASIC_AVATAR'");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question