DB_DataObject - how to insert a value for an autoincrement primary key field

From: Date: Thu, 15 Feb 2007 11:14:11 +0000
Subject: DB_DataObject - how to insert a value for an autoincrement primary key field
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-26587@lists.php.net to get a copy of this message
Hi, I'm using DB_DataObject 1.8.5 and have created DAO for my tables. One of the tables employee has a field id which is of type unsigned int and is defined as the primary key - autoincrement. When i try to insert an employee record into the table, sometimes i need to use the system generated value for id and sometimes a user defined value. when using system generated value the insert works fine $dao = new DAO_Employee(); $dao->name = "foobar"; $dao->insert(); however if i try to have a user defined id the insert does not use the value of 'id' as set in the DAO but instead generates a new one and assigns it to dao. $dao = new DAO_Employee(); $dao->id = 11231; $dao->name = "baz"; $dao->insert(); The above insert does not use id value 11231 but instead uses the next value of autoincrement. Is there anyway one can enforce the insert method to use the id value set in the dao rather than the next auto increment value ? Thanks. Yashesh Bhatia ---------------------------------------------------------------- Go Pre http://www2.localaccess.com/rlalonde/pre.htm ----------------------------------------------------------------

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