Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Monday, November 19, 2018
About Us
Magazine
Open Source
CVS
Services
Index  »  Projects  »  phpMyEdit  »  Forum  »  MySQL error 1064 with DELETE and using reservd wrd col. name

phpMyEdit Installation     MySQL error 1064 with DELETE and using reservd wrd col. name
Post new topic   Reply to topic    
 
yyacub     Joined: 21 Feb 2008   Posts: 3  
Post Posted: 2008-02-21 10:33
Back to top  Reply with quote     

this most likely belongs in the bug submission area, but I'm posting it here so people can easily find the fix,


>>> 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


>>> 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.')'; // )


>>> 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 have it changed to:
DELETE FROM 'vehicles' WHERE ('key' = 0)

and that's what the above fix does, it just mimics what the SELECT statement was doing (perhaps it was just overlooked at the time it was written?)

Perhaps the developers would prefer to code it another way, but that worked for me, and that's all I have time to be concerned with.

-Jacob

 
yyacub     Joined: 21 Feb 2008   Posts: 3  
Post Posted: 2008-02-21 10:49
Back to top  Reply with quote     

yyacub wrote:
this most likely belongs in the bug submission area....


I tried to submit the bug report, buuuut, it crashed:

Fatal error: Allowed memory size of 25165824 bytes exhausted (tried to allocate 81 bytes) in /home/platon/public_html/platon.sk/lib2/mantis/core/config_api.php on line 22

my work is done here

 
michal     Joined: 17 Jun 2003   Posts: 537   Location: Slovakia
Post Posted: 2008-02-22 10:18
Back to top  Reply with quote     

try cvs version of phpmyedit, it is fixed there (i hope :) )

michal

 
yyacub     Joined: 21 Feb 2008   Posts: 3  
Post Posted: 2008-02-22 11:33
Back to top  Reply with quote     

michal wrote:
try cvs version of phpmyedit, it is fixed there (i hope :) )


ah, I didn't check. I just knew that 5.6 did the same thing and 5.7.1 did the same thing... so, i just fixed it.


The same fix is required on the WHERE query for do_change_record() on line 2725.

hm, after this i noticed that the documentation advised against using the "key" name (for those building the tables). oh well, it seems like it'd be good programming to just fix it though. maybe someone with CVS write privileges wants to verify it's globally fixed ;-). Those were the only 2 places I located a problem. it'll add/change/delete/copy everywhere else.

 
Post new topic   Reply to topic    

Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top · Feedback form · Application form
Report bug on PLATON.SK website · Terms of use · Privacy policy