Re: My DB_DataObject subclasses are always returning 1 on insert()
| From: | Mike Zornek | Date: | Wed, 19 May 2004 16:53:34 +0000 |
| Subject: | Re: My DB_DataObject subclasses are always returning 1 on insert() | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-12624@lists.php.net to get a copy of this message | ||
On 5/19/04 12:18 PM, "Alan Knowles" <alan@akbkhome.com> wrote:
> Mike Zornek wrote:
> Learning CVS is always worth it :) - but you can grab it using these links..
>
> DataObject.php
>
> http://cvs.php.net/co.php/pear/DB_DataObject/DataObject.php?r=1.258&p=1
>
> DataObject/Error.php
>
> http://cvs.php.net/co.php/pear/DB_DataObject/DataObject/Error.php?r=1.1&p=1
>
> Regards
> Alan
I still wouldn't be comfortable manually mixing production/development
version of files around my install.
For now I've overridden insert() with:
function insert() {
/* DB_DataObject should return the last_insert_id() on it's own,
but in my experience it is returning "1" everytime. Should this
be fixed in the future, this code can prob get deleted. */
parent::insert();
// get the DB connection and ask for the last_insert_id() manually
$db = $this->getDatabaseConnection();
$result =& $db->query('SELECT LAST_INSERT_ID();');
if (DB::isError($res)) {
die($res->getMessage());
}
$row =& $result->fetchRow();
return $row[0];
}
It works as expected, and I'll look for fix in the next upgrade.
Thanks.
~ Mike
-----
Mike Zornek
Web Designer, Media Developer, Programmer and Geek
Personal site: <http://MikeZornek.com>
New Project: <http://WebDevWiki.com>