DB_DataObject::update() raises error is zero rows effected?
| From: | Mike Zornek | Date: | Thu, 13 May 2004 21:42:03 +0000 |
| Subject: | DB_DataObject::update() raises error is zero rows effected? | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-12477@lists.php.net to get a copy of this message | ||
In the process of overriding update() in my own DataObject I noticed that if
if no rows are effected by update() it returns false. The documentation make
it seem like I would get zero back:
<http://pear.php.net/manual/en/package.database.db-dataobject.db-dataobject.
update.php>
> Return value
> int number of rows affected or FALSE on failure
Zero rows does not mean failure (at least to me). Perhaps this should be
changed? My .02 -- though am open-minded to hearing why it should be false.
My current override looks like:
function update($dataObject = false) {
$ret = parent::update($dataObject);
if ($ret === false) {
return false;
}
// special stuff here
return true;
}
The reason I'm doing this is because my DataObject has an array or other
DataObjects in it, and I need to call updates on them, when the top object
gets update called on it. I'd like to have the error checking in place, but
seeing as how I'm getting false instead of zero from the parent update (as I
was expecting from the docs) it's hard to know if something went wrong or
not.
Please offer advice if you have it. Thanks!!
~ Mike
-----
Mike Zornek
Web Designer, Media Developer, Programmer and Geek
Personal site: <http://MikeZornek.com>
New Project: <http://WebDevWiki.com>