Re: Re: DB_Dataobject insert() returning null
| From: | Daniel Brandauer | Date: | Mon, 28 Feb 2005 02:18:47 +0000 |
| Subject: | Re: Re: DB_Dataobject insert() returning null | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-17717@lists.php.net to get a copy of this message | ||
One thing I noticed, your create table statement lists the table name as
'subscriber' (lower-case 's'), but when you call the factory method you
refer to the table as 'Subscriber' (upper-case 'S'). Not sure if it
matters, but consistency can help reduce bugs sometimes :)
-Daniel
On Mon, 2005-02-28 at 09:03 +0800, Alan wrote:
>It should work, however check with
>http://pear.php.net/manual/en/package.database.db-dataobject.db-dataobject.insert.php
>
>to see why it may not work.. (otherwise try the CVS version, or you may
>have to go on a bug hunting trip..)
>
>Regards
>Alan
>
>On Fri, 2005-02-25 at 17:48 +0000, Peter Bowyer 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();
>>
>> Any ideas why?
>>
>> Thanks,
>> Peter
>>
>
--
Daniel Brandauer <daniel@heiseysoft.com>