phpMyEdit - Viewing Bug Advanced Details [ Go Back ]
554 core / field option major always 2008-09-15 17:55 2008-09-15 17:55
genio any  
any  
normal any  
new 5.6 (stable)  
open  
none  
none  
CHangelog keycol 0 on auto increment
Seems like that the changelog function which inserts the colum id when inserting a new row sends 0 when the id is set to autoinrement. This in theory is not wrong as on the form if you set an ID field as autoincrement, it will be 0, and the DB interprets that to be changed to the next available number in a id key field.

However, for the purpose of the change log, this is incorrect.

You currently use;

$query = sprintf('INSERT INTO %s'
.' (updated, user, host, operation, tab, rowkey, col, oldval, newval)'
.' VALUES (NOW(), "%s", "%s", "insert", "%s", "%s", "", "", "%s")',
$this->logtable, addslashes($this->get_server_var('REMOTE_USER')),
addslashes($this->get_server_var('REMOTE_ADDR')), addslashes($this->tb),
addslashes($key_col_val), addslashes(serialize($newvals)));

but in fact should be

$query = sprintf('INSERT INTO %s'
.' (updated, user, host, operation, tab, rowkey, col, oldval, newval)'
.' VALUES (NOW(), "%s", "%s", "insert", "%s", "%s", "", "", "%s")',
$this->logtable, addslashes($this->get_server_var('REMOTE_USER')),
addslashes($this->get_server_var('REMOTE_ADDR')), addslashes($this->tb),
addslashes($this->rec), addslashes(serialize($newvals)));

as this guarantees that the correct field is used, either if in uatoincrement mode, or if the user has assigned itself the id
Always, set an autoincremnt ID, add a new row, changelog will report the id as 0
trevial fix, but quite a tricky one as I see numerous posts that have this issue

There are no notes attached to this bug.