ok, i have this interface.
interface i_db
{
/*
* make a database connection
*/
public function __construct($dbhost,$dbuser,$dbpass,$dbname);
/*
* close database connection.
*/
public function __deconstruct();
/*
* query the database.
* returns true or false for insert / update.
* or
* returns result resource for select.
*/
public function query($sql);
/*
* fetch a database row.
* returnsa row from the database as an object.
*/
public function fetch();
/*
* retrieve number of rows returned by last query.
*/
public function numrows();
/*
* return number of rows effected by last query.
*/
public function affected();
/*
* retieve the id of the last inserted row.
*/
public function lastid();
}
for which i am trying to build both a mysql and a postgres database object. the problem i am having is that postgres doesn't seem to have an equivelent to mysql's mysql_insert_id() function, so im having trouble creating my lastid() method.
for the mysql (which i havent yet built) i could easily use something like.
public function lastid()
{
return mysql_last_id($this->result);
}
and be done. with postgres, it appears i have to run a query something like...
"SELECT CURRVAL('$seq_name') AS seq"
the problem is, i have no way of passing in the $seq_name variable. as you can see by my interface, there are no arguments to this method, and really, i dont want to have to add one, because then i would have to pass an argument even when im using mysql. get what i meen?
is there a better way of getting the last inserted records id in postgres? ive only just started using postgres, so im still learning stuff. im using 8.0
ps: at this point in time i can still make changes to the interface, i just dont really want to have to pass a useless argument to mysql's implimenation of my object. i suppose i could make it optional, but, surely there is a better way.