Re: DB_Dataobject insert() returning null

From: Date: Sat, 26 Feb 2005 01:17:02 +0000
Subject: Re: DB_Dataobject insert() returning null
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-17694@lists.php.net to get a copy of this message
On Fri, 25 Feb 2005 17:48:25 +0000, Peter Bowyer <peter@mapledesign.co.uk> wrote: > Hi, > > I have a DataObject for the table shown below. My ini file lists a key > column, so I believe this should work. Yet the value of $record_id is NULL. > > CREATE TABLE subscriber ( > user_id int(10) unsigned NOT NULL auto_increment, > username varchar(45) NOT NULL default '', > password varchar(32) NOT NULL default '', > firstname varchar(45) NOT NULL default '', > lastname varchar(45) NOT NULL default '', > ... > PRIMARY KEY (user_id) > ) TYPE=MyISAM; > > And the code: > $s =& DB_DataObject::factory('Subscriber'); > $s->setRowValues($_POST); > $s->role = 1; // Basic user > $record_id = $s->insert(); insert() *does not* return the key. The key is set in the DO. So $record_id = $s->user_id should get you what you want. > > Any ideas why? > -- Justin Patrin

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