Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.11.5

Request #6555 Can't update register with id 0
Submitted: 2006-01-23 03:51 UTC
From: vtamara Assigned:
Status: Suspended Package: DB_DataObject
PHP Version: Irrelevant OS: Any
Roadmaps: (Not assigned)    
Subscription  


 [2006-01-23 03:51 UTC] vtamara at pasosdejesus dot org
Description: ------------ The function update (even in CVS) includes the following piece of code: if (empty($this->{$keys[0]}) && $dataObject !== true) { $this->raiseError("update: trying to perform an update without the key set, and argument to update is not DB_DATAOBJECT_WHEREADD_ONLY ", DB_DATAOBJECT_ERROR_INVALIDARGS); return false; } Since the empty function returns true when its argument is 0, the error is produced also when the key of the DataObject is 0. In my humble opinion the condition of the if should be: if ($this->{$keys[0]}!=0 && empty($this->{$keys[0]}) && $dataObject !== true) { Am I right? Best regards. Thanks for the good work. God illuminate us.

Comments

 [2006-01-23 05:09 UTC] alan_k
I'm not sure allowing update etc. to work with a '0' value is a good idea.... Making the code explicit (eg. by doing a raw query when using odd stuff like '0' based keys' seems like a good idea..) leaving this open to think about..
 [2010-04-26 04:09 UTC] alan_k (Alan Knowles)
-Status: Open +Status: Suspended
No real justification seen for allowing updates on anything when the primary key is set to '0' ...