Search Postgresql Archives

Re: OID Usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Christian Kratzer wrote:

why should your application not want to know about the metadata of it's
own tables ? That sounds quite strange when you think about it.

Well, the ideer is to be compatible with mysql at the same level in the code. This works nicely, as I have descriped, but I am concerned if there is any strains attached to this method.


It is all found in the : http://lue.dk/prj/dbc/index.html

If you name your sequences in a generic way you can alway construct the name of the sequence from the name of the table and the id column.

We use this in our php framework

function insert_id()
{
global $pg_conn;
if(isset($pg_conn)) {
$query = sprintf("SELECT currval('%s_%s_seq') AS id",$this->table,$this->id_column);
$result = @pg_query($pg_conn,$query);
$row = pg_fetch_assoc($result);
return strval($row["id"]);
} else {
return 0;
}
}

Thanks, but this demands you to have the table and id_column name in your hand, and I don't right now.


Also ... the "currval" function are specifik to postgresql, and there are nothing like it in mysql that can make any garanti for getting row for newly inserted data. You can access autoincrement values in mysql, but no garanties are given about its value (someone else have inserted a new in the same table).

But thanks for your interrest., anyway.

/BL

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux