Re: Bug #17554 [Fbk]: Err in update when primary key = 0
| From: | Jacek Pawlowski | Date: | Mon, 05 Jul 2010 17:19:49 +0000 |
| Subject: | Re: Bug #17554 [Fbk]: Err in update when primary key = 0 | ||
| References: | 1 | Groups: | php.pear.qa |
| Request: | Send a blank email to pear-qa+get-5702@lists.php.net to get a copy of this message | ||
I tried:
$x = new DataObjects_GLOBAL;
$x -> whereAdd('id=0');
$x -> COMMENT = date("Y-m-d H:i:s");
$x -> update(DB_DATAOBJECT_WHEREADD_ONLY);
works.
and as per request below:
$x = new DataObjects_GLOBAL;<< always use factory!!!
$x->whereAdd('1=1'); // update all columns?
$x -> COMMENT = date("Y-m-d H:i:s");
$x -> update(DB_DATAOBJECT_WHEREADD_ONLY);
all rows have been updated.
-- jacek
On 07/04/2010 09:03 PM, PEARBug Database wrote:
ATTENTION! Do NOT reply to this email! To reply, use the web interface found at http://pear.php.net/bugs/bug.php?id=17554&edit=2-- *Jacek Pawlowski* <mailto:jacek@myecho.ca> <mailto:jacek@myecho.ca> www.myecho.ca <http://www.myecho.ca> 2318 Kilmarnock Cr. V7J 2Z2, Canada North Vancouver, BC <http://maps.google.com/maps?f=q&hl=en&q=2318+Kilmarnock+Crescent,+North+Vancouver+District,+British+Columbia,+Canada&sll=37.0625,-95.677068&sspn=46.36116,114.433594&ie=UTF8&z=16&iwloc=addr&om=1> t:604.990.4346 f:604.648.9827 c:604.671.6346 ------------------------------------------------------------------------ *echo software systems inc.* <http://www.myecho.ca> *Warehouse Information Network* <http://www.mywin.ca>ID: 17554 Updated by: alan@akbkhome.com Reported By: jacek at myecho dot ca Summary: Err in update when primary key = 0 Status: Feedback Type: Bug Package: DB_DataObjectOperating System: Linux fedora 11 Package Version: 1.9.4PHP Version: 5.2.10Roadmap Versions: New Comment: $x = new DataObjects_GLOBAL;<< always use factory!!! $x->whereAdd('1=1'); // update all columns? $x -> COMMENT = date("Y-m-d H:i:s"); $x -> update(DB_DATAOBJECT_WHEREADD_ONLY); Previous Comments: ------------------------------------------------------------------------ [2010-07-05 04:02:35] alan_k -Status: Open +Status: Feedback have you tried ->update(DB_DATAOBJECT_WHEREADD_ONLY) ------------------------------------------------------------------------ [2010-07-02 22:47:09] jacek Description: ------------ update doesn't work when primary key value is 0 (zero). it works when primary key value is not zero Test script: --------------- $x = new DataObjects_GLOBAL; $x -> get(0); $x -> COMMENT = date("Y-m-d H:i:s"); $x -> update(); the table: CREATE TABLEGLOBAL(idint(11) unsigned NOT NULL,COMMENTvarchar(16) COLLATE latin1_general_ci NOT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci Expected result: ---------------- COMMENT should be updated with current date-time Actual result: -------------- err:DataObjects_GLOBAL2 : ERROR : update: trying to perform anupdate withoutthe key set, and argument to update is not DB_DATAOBJECT_WHEREADD_ONLY------------------------------------------------------------------------