Help! PHP & PostgreSQL/SQLite/MSSQL
Posted: Fri Sep 23, 2011 3:07 pm
Hello everyone,
I used to develop all my projects using MySQL databases... But now I want to change a bit and offer more than one choice... So I was looking for equivalent functions for mysql_insert_id() function, but it seems that not all the database engines handle that, that's what I found:
PostgreSQL equivalent: pg_last_oid($row)
$row is apparently the variable of the last query inserted in database, unlike MySQL, PgSQL needs to know which query was last ran?
Also, they mentioned that the OID (return value) is a STRING not and INTEGER, what is exactly OID so?
SQLite equivalent: sqlite_last_insert_rowid($dbhandler)
what is $dbhandler?
MSSQL equivalent would be the following function:
function mssql_lastid()
{
$id = 0;
$res = mssql_query("SELECT @@identity AS id");
if ($row = mssql_fetch_row($res)) $id = $row[0];
return $id;
}
Is that right?
Thanks
I used to develop all my projects using MySQL databases... But now I want to change a bit and offer more than one choice... So I was looking for equivalent functions for mysql_insert_id() function, but it seems that not all the database engines handle that, that's what I found:
PostgreSQL equivalent: pg_last_oid($row)
$row is apparently the variable of the last query inserted in database, unlike MySQL, PgSQL needs to know which query was last ran?
Also, they mentioned that the OID (return value) is a STRING not and INTEGER, what is exactly OID so?
SQLite equivalent: sqlite_last_insert_rowid($dbhandler)
what is $dbhandler?
MSSQL equivalent would be the following function:
function mssql_lastid()
{
$id = 0;
$res = mssql_query("SELECT @@identity AS id");
if ($row = mssql_fetch_row($res)) $id = $row[0];
return $id;
}
Is that right?