Re: [PEAR-BUG] Bug #17554 [Fbk]: Err in update when primary key = 0

[email protected] (Jacek Pawlowski)
Newsgroups php.pear.qa
Message-ID <[email protected]>
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
>
>
>   ID:               17554
>   Updated by:       [email protected]
>   Reported By:      jacek at myecho dot ca
>   Summary:          Err in update when primary key = 0
>   Status:           Feedback
>   Type:             Bug
>   Package:          DB_DataObject
>   Operating System: Linux fedora 11
>   Package Version:  1.9.4
>   PHP Version:      5.2.10
>   Roadmap 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 TABLE `GLOBAL` (
>    `id` int(11) unsigned NOT NULL,
>    `COMMENT` varchar(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 an
> update without
>                          the key set, and argument to update is not
>                          DB_DATAOBJECT_WHEREADD_ONLY
>
> ------------------------------------------------------------------------
>
>
>
>    

-- 
*Jacek Pawlowski* <mailto:[email protected]>
<mailto:[email protected]>
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>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.