Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Sobota, 28. november 2026
O nás
Magazín
Otvorený softvér
CVS
Služby
Index  »  Projekty  »  phpMyEdit  »  Fórum  »  MySQL error 1064 with DELETE and using reservd wrd col. name

phpMyEdit Installation     MySQL error 1064 with DELETE and using reservd wrd col. name
Odoslať novú tému   Odpovedať na tému    
 
yyacub     Založený: 21.02.2008   Príspevky: 3  
Príspevok Zaslal: 2008-02-21 10:33
Návrat hore  Odpovedať s citátom     

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     Založený: 21.02.2008   Príspevky: 3  
Príspevok Zaslal: 2008-02-21 10:49
Návrat hore  Odpovedať s citátom     

yyacub Napísal:
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     Založený: 17.06.2003   Príspevky: 537   Bydlisko: Slovakia
Príspevok Zaslal: 2008-02-22 10:18
Návrat hore  Odpovedať s citátom     

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

michal

 
yyacub     Založený: 21.02.2008   Príspevky: 3  
Príspevok Zaslal: 2008-02-22 11:33
Návrat hore  Odpovedať s citátom     

michal Napísal:
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.

 
Odoslať novú tému   Odpovedať na tému    

Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok · Odkazový formulár · Prihláška
Upozorniť na chybu na PLATON.SK webstránke · Podmienky použitia · Ochrana osobných údajov