Re: DB_DataObject skip sequence

From: Date: Wed, 13 Apr 2005 16:50:06 +0000
Subject: Re: DB_DataObject skip sequence
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-18730@lists.php.net to get a copy of this message
Justin Patrin wrote:
On 4/13/05, Robin Ericsson <robin.ericsson@profecta.se> wrote:
Hi, Is it possible to tell DB_DataObject to just skip using sequence on a field defined as primary key?
I'm not sure what you're asking. Is this field set up as a PK in your table? Is it set up as a sequence? Is DB_DO using DB's sequence methods and you don't want that?
Mysql table: CREATE TABLE person_tokens ( person_id bigint(20) NOT NULL default '0', token char(40) NOT NULL default '', expire datetime default NULL, PRIMARY KEY (person_id), KEY idx_token (token) ); This is the table from DB_DO:
    var $__table = 'person_tokens';                   // table name
    var $person_id;                       // int(20)  not_null primary_key
    var $token;                           // string(40)  not_null multiple_key
    var $expire;                          // datetime(19)
$po = new Person_Tokens; $po->person_id = 3; $po->token = $token; $po->insert(); this causes DB_DO to create a sequence and try to add "1" as person_id instead of the 3 I've put in it.
I've tried to add a method called sequenceKey() which returned array('field', true, false), but in that case the field wasn't used at all in the query.
perhaps try array('field', false, false)?
That results as DB_DO still using a sequence instead of "3". regards, Robin

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