Re: Re: DataObjects: override insert value
| From: | Alan Knowles | Date: | Tue, 08 Jun 2004 05:06:38 +0000 |
| Subject: | Re: Re: DataObjects: override insert value | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-12991@lists.php.net to get a copy of this message | ||
dont_use_pear_sequences = true
only helps if you are using non-native sequences (eg. not auto_increment or nextval())
what you are trying to do is a little 'odd' - and is not really within the 98% functionality that dataobject tries to provide..
If you really need to do that:
function insertWithID() {
$this->query("insert into {$this->__table} (id) values ({this->id})");
$x = new DataObject_foo;
$x->get($this->id);
$x->setFrom($this);
$x->update();
}
or you could
a) remove the auto_increment feature on the database, as you are not using it.
b) override keys() to return an empty array()
Regards
Alan
The Linux_kid wrote:
Thank you, but doesn't work. -> Try setting this in your DataObject.ini: -> -> dont_use_pear_sequences = true -> > I've last DB and DataObjects version, -> > and I've a table with Key field as "autonumeric". -> > -> > example: -> > -> > Table foo -> > -------- -> > id --> KeyValue (autonumeric) -> > name --> string -> > model --> string -> > ... -> > -> > Everything is right, but sometimes, I need -> > to set a specific value to "Field bar1", -> > then, if I prepare: -> > -> > $foo=new DataObejcts:foo(); -> > -> > $foo->id="16"; -> > $foo->name="toyota" -> > -> > $foo->insert(); -> > -> > BUT, last insert doesn't put me a $id="16" on DataBase. -> > how ever, if I make a pure MySQL query, it accept -> > my id="16" succefully -> > -> > how can I make this with DataObjects? -> > -> > Thanks ! -> > andres. ->-- Can you help out? Need Consulting Services or Know of a Job? http://www.akbkhome.com