Re: DataObjects , postgresql and sequences

From: Date: Thu, 03 Apr 2003 14:24:18 +0000
Subject: Re: DataObjects , postgresql and sequences
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-4626@lists.php.net to get a copy of this message
[...}
i tryed : require_once('DataObjects/mytable.php'); $station = new DO_mytable; $station->sta_nom = 'courchevel'; $id = $station->insert(); but postgres returns an error code: INSERT INTO mytable (sta_nom ) VALUES ('courchevel' ) [nativecode=ERROR: ExecInsert: Fail to add null value in not null attribute sta_id ] I understand this error, but what is the proper code to avoid that ? what is the way to insert the id just extracted from the sequence ?
Me again, ;) In fact the real question is: do i have to create a db connection and extracting the nextId before using it in Dataobjects ? in this case the way would be : $db = DB::Connect($dsn); $nextId = $db->nextId('mytable'); require_once('DataObjects/mytable.php'); $station = new DO_mytable; $station->stat_id = $nextId; $station->sta_nom = 'courchevel'; $station->insert(); But... do i really need to initiate a DB::Connect before using dataObjets ? thanks again Xavier

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