DB_Dataobject Insert Problem with getting id
| From: | Sebastian Ganschow | Date: | Sun, 23 Oct 2005 21:28:16 +0000 |
| Subject: | DB_Dataobject Insert Problem with getting id | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-21610@lists.php.net to get a copy of this message | ||
Hi,
we've got a Problem with getting an id when we call $do->insert().
The Dataobject is configured with ignore_sequence_keys = ALL and the field
id in the table is set as auto_increment. Normaly the method insert should
return the key, which was set to the dataset, but it returns true.
I've locked at the source code of Dataobject and in the method getSequenceKey()
on line 1944 if found this block:
if (!empty($_DB_DATAOBJECT['CONFIG']['ignore_sequence_keys'])) {
$ignore = $_DB_DATAOBJECT['CONFIG']['ignore_sequence_keys'];
if (is_string($ignore) && (strtoupper($ignore) == 'ALL')) {
return $_DB_DATAOBJECT['SEQUENCE'][$this->_database][$this->__table] = array(false,false,$seqname);
}
if (is_string($ignore)) {
$ignore = $_DB_DATAOBJECT['CONFIG']['ignore_sequence_keys'] = explode(',',$ignore);
}
if (in_array($this->__table,$ignore)) {
return $_DB_DATAOBJECT['SEQUENCE'][$this->_database][$this->__table] = array(false,false,$seqname);
}
}
The array which is returned by getSequenceKey contains the information, if the native
key should be used at index 1. Here it is set to false, so the insert method doesn't use
the key return by the Database. If I change array(false,false,$seqname) into
array($usekey,true,$seqname) I get the key from the insert method.
So is this a bug or do I have an error in my configuration?
Thanks,
Sebastian