Changeset 4892 for trunk/include/dblayer


Ignore:
Timestamp:
Feb 15, 2010, 8:49:04 PM (14 years ago)
Author:
nikrou
Message:

Feature 1255 :
update pwg_db_insert_id() function.
PosgreSQL needs table name to retrieve last insert auto increment id.

Location:
trunk/include/dblayer
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/dblayer/functions_mysql.inc.php

    r4833 r4892  
    158158}
    159159
    160 function pwg_db_insert_id()
     160function pwg_db_insert_id($table=null, $column='id')
    161161{
    162162  return mysql_insert_id();
  • trunk/include/dblayer/functions_pgsql.inc.php

    r4886 r4892  
    193193}
    194194
    195 function pwg_db_insert_id()
    196 {
    197   // select currval('piwigo_user_id_seq');
     195function pwg_db_insert_id($table=null, $column='id')
     196{
     197  $sequence = sprintf('%s_%s_seq', strtolower($table), $column);
     198  $query = '
     199SELECT CURRVAL(\''.$sequence.'\');';
     200
     201  list($id) = pwg_db_fetch_row(pwg_query($query));
     202
     203  return $id;
    198204}
    199205
  • trunk/include/dblayer/functions_sqlite.inc.php

    r4833 r4892  
    215215}
    216216
    217 function pwg_db_insert_id()
     217function pwg_db_insert_id($table=null, $column='id')
    218218{
    219219  global $pwg_db_link;
Note: See TracChangeset for help on using the changeset viewer.