phpMyEdit - Viewing Bug Advanced Details [ Go Back ]
514 core / general feature always 2008-02-21 10:47 2008-02-21 10:47
yyacub PHP 4.4.8  
Linux (v??)  
normal MySQL 4.1.22  
new 5.7.1 (stable)  
1.204 open  
none  
none  
MySQL error 1064 with DELETE command and using "key" as the column name in a table
>>> SCENARIO <<<

Deleting a record from a table that uses the name "key" as the name of the key column.


>>> THE ERROR <<<

MySQL 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 = 0)' at line 1
use phpMyEdit on a table with "key" as the name of the key column
>>> DETAILS <<<

It was trying to execute:
DELETE FROM vehicles WHERE (key = 0)

but MySQL got all excited about using the name "key" as the column name, sooo just do what the SELECT statement was doing in the same function and add ticks around the table/column names like:
DELETE FROM 'vehicles' WHERE ('key' = 0)

Mimicking the SELECT statement query coding in the same function yields the following:

>>> THE FIX <<<

version: phpMyEdit.class.php,v 1.204
function: do_delete_record()
line: 2777-2778
CHANGE:

$query = 'DELETE FROM '.$this->tb.' WHERE ('.$this->key.' = '
.$this->key_delim.$this->rec.$this->key_delim.')'; // )

TO:

$query = 'DELETE FROM '.$this->sd.$this->tb.$this->ed.' WHERE ('.$this->sd.$this->key.$this->ed.' = '
.$this->key_delim.$this->rec.$this->key_delim.')'; // )


Perhaps there is a more appropriate way to code it, but it worked for me, and that's as far as I have time to take it.

There are no notes attached to this bug.