Changeset 4892


Ignore:
Timestamp:
02/15/10 20:49:04 (10 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
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/history.php

    r4325 r4892  
    137137    pwg_query($query); 
    138138 
    139     $search_id = pwg_db_insert_id(); 
     139    $search_id = pwg_db_insert_id(SEARCH_TABLE); 
    140140 
    141141    redirect( 
     
    199199    pwg_query($query); 
    200200 
    201     $search_id = pwg_db_insert_id(); 
     201    $search_id = pwg_db_insert_id(SEARCH_TABLE); 
    202202 
    203203    redirect( 
  • trunk/admin/include/functions.php

    r4833 r4892  
    12551255    ); 
    12561256 
    1257   $inserted_id = pwg_db_insert_id(); 
     1257  $inserted_id = pwg_db_insert_id(CATEGORIES_TABLE); 
    12581258 
    12591259  $query = ' 
     
    13881388      ); 
    13891389 
    1390     $page['tag_id_from_tag_name_cache'][$tag_name] = pwg_db_insert_id(); 
     1390    $page['tag_id_from_tag_name_cache'][$tag_name] = pwg_db_insert_id(TAGS_TABLE); 
    13911391  } 
    13921392  else 
     
    16631663      ); 
    16641664 
    1665     $inserted_id = pwg_db_insert_id(); 
     1665    $inserted_id = pwg_db_insert_id(TAGS_TABLE); 
    16661666 
    16671667    return array( 
  • 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; 
  • trunk/include/functions_comment.inc.php

    r4325 r4892  
    169169    pwg_query($query); 
    170170 
    171     $comm['id'] = pwg_db_insert_id(); 
     171    $comm['id'] = pwg_db_insert_id(COMMENTS_TABLE); 
    172172 
    173173    if (($comment_action=='validate' and $conf['email_admin_on_comment']) or 
  • trunk/include/ws_functions.inc.php

    r4884 r4892  
    12481248    ); 
    12491249 
    1250   $image_id = pwg_db_insert_id(); 
     1250  $image_id = pwg_db_insert_id(IMAGES_TABLE); 
    12511251 
    12521252  // let's add links between the image and the categories 
  • trunk/qsearch.php

    r4325 r4892  
    6161;'; 
    6262  pwg_query($query); 
    63   $search_id = pwg_db_insert_id(); 
     63  $search_id = pwg_db_insert_id(SEARCH_TABLE); 
    6464} 
    6565 
  • trunk/search.php

    r4753 r4892  
    149149    pwg_query($query); 
    150150 
    151     $search_id = pwg_db_insert_id(); 
     151    $search_id = pwg_db_insert_id(SEARCH_TABLE); 
    152152  } 
    153153  else 
  • trunk/upload.php

    r4325 r4892  
    249249    $query.= ';'; 
    250250    pwg_query( $query ); 
    251     $page['waiting_id'] = pwg_db_insert_id(); 
     251    $page['waiting_id'] = pwg_db_insert_id(WAITING_TABLE); 
    252252 
    253253    if ($conf['email_admin_on_picture_uploaded']) 
Note: See TracChangeset for help on using the changeset viewer.