Re: Issue has returned with update() not returning true.

From: Date: Wed, 22 Jun 2005 15:23:15 +0000
Subject: Re: Issue has returned with update() not returning true.
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-19725@lists.php.net to get a copy of this message
On 6/22/05, Dan Rossi <pear@electroteque.org> wrote: > > On 22/06/2005, at 4:50 PM, Dan Rossi wrote: > > > Somehow this issue was working and now has arisen, the problem with > > the update method is I am checking if it has returned true and > > commited the transaction ie > > > > $this->query("BEGIN"); > > if (parent::update()) { > > $this->query("COMMIT"); > > } else { > > $this->query("ROLLBACK"); > > } > > > > > > > Arrggh, if there is nothing to update it returns false , hence is > rolling back , is there a better way to setup transactions in a DO ? > "Nothing to update" meaning you're doing a manual query basically? If you fetch a record and update it there will always be an update happening. And no, DB_DO does not return false if there is "nothing to update". In the case where you run update on a fetched object a query is always run unless you pass in a DO and it finds no differences (this returns true). In the case where you are doing a "manual" update (i.e. doing a whereAdd instead of fetching a record) then it will return the affected rows, as expected. Try doing a var_dump of the return value. It's likelu 0, not false. If if is false then you have an error. Turn on debugging to see what's happening. -- Justin Patrin

« previous php.pear.general (#19725) next »