Re: DB_pgsql.php - adding native lookup for sequences? Re: RES: RES: [PEAR-DEV] DataObjects insert() for pgsql
| From: | Alan Knowles | Date: | Sat, 11 Oct 2003 09:30:41 +0000 |
| Subject: | Re: DB_pgsql.php - adding native lookup for sequences? Re: RES: RES: [PEAR-DEV] DataObjects insert() for pgsql | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-22583@lists.php.net to get a copy of this message | ||
Currently both MDB&DB use sequences in some format for all databases..
usually the sequence name is assumed to be {table}_seq, or you can manually specify it using $seq_name
The idea of the query/code previously is that rather than use a fixed name/or user configured name, it asks the database to tell it what sequence a particular table uses...
eg.
if a table is
table mytable (
id default nextval(mysequence),
name varchar(32)
)
you would do something like:
$nextid = $db->nextId('mytable',false, 'id');
it could then run the query.. find the seqence 'mysequence' from the database and get the nextval of it.. (hence keeping in sync the database from access not via the DB api..)
Hope that helps explain :)
Regards
alan
Lukas Smith wrote:
-- Can you help out? Need Consulting Services or Know of a Job? http://www.akbkhome.comFrom: Alan Knowles [mailto:alan@akbkhome.com] Sent: Saturday, October 11, 2003 6:47 AMI've been pondering if this should really go into the postgres driver for DB, either as an additional argument for nextId: eg. function nextId($seq_name, $ondemand = true,$lookup = false) or as an extra method: function nextIdNative($table) { .... Any thoughts.. - it seems a bit more generic/usefull for DB..Could you summarize this feature .. I admit I am too lazy to dig through the thread to understand what this feature would do :-) Regards, Lukas