DB_DataObject error ?

From: Date: Wed, 28 Jan 2004 12:47:32 +0000
Subject: DB_DataObject error ?
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-10403@lists.php.net to get a copy of this message
Hello, I am using a table named "busy" (MySQL): CREATE TABLE busy ( id_per mediumint(6) unsigned NOT NULL default '0', id mediumint(8) unsigned NOT NULL default '0', ts timestamp(14) NOT NULL, PRIMARY KEY (id_per,id), UNIQUE KEY id (id), KEY ts (ts) ) TYPE=MyISAM "id_per" is representing a person, and "id" is representing an object both of them are foreign keys ! this table is used to attribute objects (id) to persons (id_per), one person may hold several objects, but an object may not be holded by more than one person (reason of Unique key: "id") so, i am using the following code to say => reserve object id '5' to person id '18': =============== $busy = new DataObjects_Busy; $busy->setid(5); $busy->setid_per(18); $busy->insert(); =============== But DB_DataObject generate this: DB_DataObject: SENT: INSERT INTO busy (id ) VALUES ( 18 ) because it thinks that id_per is an autoincrement !! This is the part of code of function insert() of DataObject.php that skip the autoincrement // if we are using autoincrement - skip the column... if ($key && ($k == $key)) { continue; } I guess this condition test if this is the primary key and not if it is an autoincrement value !! am i right ? Patrick

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