Re: DB_Dataobject Insert Problem with getting id
| From: | Justin Patrin | Date: | Mon, 24 Oct 2005 15:58:46 +0000 |
| Subject: | Re: DB_Dataobject Insert Problem with getting id | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-21612@lists.php.net to get a copy of this message | ||
On 10/23/05, Sebastian Ganschow <sebastian@ganschow.net> wrote:
> 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
Well...this is happening *because* you have ignore_sequence_keys set
to 'ALL'. Perhaps you have this set wrong?
> 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
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Justin Patrin