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

Request #6555 Can't update register with id 0
Submitted: 2006-01-22 22:51 UTC Modified: 2006-01-23 00:10 UTC
From: vtamara at pasosdejesus dot org Assigned:
Status: Open Package: DB_DataObject
PHP Version: Irrelevant OS: Any
Roadmaps: (Not assigned)    
Subscription  
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes. If this is not your bug, you can add a comment by following this link. If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: vtamara at pasosdejesus dot org
New email:
PHP Version: Package Version: OS:

 

 [2006-01-22 22: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 00: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..