Changeset 4325 for trunk/include


Ignore:
Timestamp:
Nov 20, 2009, 3:17:04 PM (14 years ago)
Author:
nikrou
Message:

Feature 1244 resolved
Replace all mysql functions in core code by ones independant of database engine

Fix small php code synxtax : hash must be accessed with [ ] and not { }.

Location:
trunk/include
Files:
2 added
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/calendar_monthly.class.php

    r4265 r4325  
    232232  $result = pwg_query($query);
    233233  $items=array();
    234   while ($row = mysql_fetch_assoc($result))
     234  while ($row = pwg_db_fetch_assoc($result))
    235235  {
    236236    $y = substr($row['period'], 0, 4);
     
    284284  $result = pwg_query($query);
    285285  $items=array();
    286   while ($row = mysql_fetch_assoc($result))
     286  while ($row = pwg_db_fetch_assoc($result))
    287287  {
    288288    $m = (int)substr($row['period'], 0, 2);
     
    334334  $items=array();
    335335  $result = pwg_query($query);
    336   while ($row = mysql_fetch_assoc($result))
     336  while ($row = pwg_db_fetch_assoc($result))
    337337  {
    338338    $d = (int)$row['period'];
     
    352352    unset ( $page['chronology_date'][CDAY] );
    353353
    354     $row = mysql_fetch_assoc(pwg_query($query));
     354    $row = pwg_db_fetch_assoc(pwg_query($query));
    355355    $items[$day]['tn_url'] = get_thumbnail_url($row);
    356356    $items[$day]['file'] = $row['file'];
  • trunk/include/category_cats.inc.php

    r4265 r4325  
    7676$image_ids = array();
    7777
    78 while ($row = mysql_fetch_assoc($result))
     78while ($row = pwg_db_fetch_assoc($result))
    7979{
    8080  $row['is_child_date_last'] = @$row['max_date_last']>@$row['date_last'];
     
    109109;';
    110110      $subresult = pwg_query($query);
    111       if (mysql_num_rows($subresult) > 0)
     111      if (pwg_db_num_rows($subresult) > 0)
    112112      {
    113         list($image_id) = mysql_fetch_row($subresult);
     113        list($image_id) = pwg_db_fetch_row($subresult);
    114114      }
    115115    }
     
    137137  ;';
    138138      $subresult = pwg_query($query);
    139       if (mysql_num_rows($subresult) > 0)
     139      if (pwg_db_num_rows($subresult) > 0)
    140140      {
    141         list($image_id) = mysql_fetch_row($subresult);
     141        list($image_id) = pwg_db_fetch_row($subresult);
    142142      }
    143143    }
     
    179179;';
    180180    $result = pwg_query($query);
    181     while ($row = mysql_fetch_assoc($result))
     181    while ($row = pwg_db_fetch_assoc($result))
    182182    {
    183183      $dates_of_category[ $row['category_id'] ] = array(
     
    203203;';
    204204  $result = pwg_query($query);
    205   while ($row = mysql_fetch_assoc($result))
     205  while ($row = pwg_db_fetch_assoc($result))
    206206  {
    207207    $thumbnail_src_of[$row['id']] = get_thumbnail_url($row);
  • trunk/include/category_default.inc.php

    r3491 r4325  
    4646;';
    4747  $result = pwg_query($query);
    48   while ($row = mysql_fetch_assoc($result))
     48  while ($row = pwg_db_fetch_assoc($result))
    4949  {
    5050    $row['rank'] = $rank_of[ $row['id'] ];
  • trunk/include/common.inc.php

    r4280 r4325  
    9393include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
    9494@include(PHPWG_ROOT_PATH. 'include/config_local.inc.php');
     95include(PHPWG_ROOT_PATH .'include/dblayer/functions_mysql.inc.php');
    9596
    9697if(isset($conf['show_php_errors']) && !empty($conf['show_php_errors']))
     
    105106
    106107// Database connection
    107 @mysql_connect( $conf['db_host'], $conf['db_user'], $conf['db_password'] ) or my_error( 'mysql_connect', true );
    108 @mysql_select_db( $conf['db_base'] ) or my_error( 'mysql_select_db', true );
    109 
    110 defined('PWG_CHARSET') and defined('DB_CHARSET')
    111   or fatal_error('PWG_CHARSET and/or DB_CHARSET is not defined');
    112 if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') )
    113 {
    114   if (DB_CHARSET!='')
    115   {
    116     pwg_query('SET NAMES "'.DB_CHARSET.'"');
    117   }
    118 }
    119 elseif ( strtolower(PWG_CHARSET)!='iso-8859-1' )
    120 {
    121   fatal_error('PWG supports only iso-8859-1 charset on MySql version '.mysql_get_server_info());
    122 }
     108$pwg_db_link = pwg_db_connect($conf['db_host'], $conf['db_user'],
     109                              $conf['db_password'], $conf['db_base'])
     110  or my_error('pwg_db_connect', true);
     111
     112pwg_db_check_charset();
    123113
    124114load_conf_from_db();
  • trunk/include/functions.inc.php

    r4265 r4325  
    4545  // columns are 'Field', 'Type'
    4646  $result = pwg_query('desc '.$table);
    47   while ($row = mysql_fetch_assoc($result))
     47  while ($row = pwg_db_fetch_assoc($result))
    4848  {
    4949    // we are only interested in the the field given in parameter for the
     
    6060    }
    6161  }
    62   mysql_free_result($result);
     62  pwg_db_free_result($result);
    6363  return $options;
    6464}
     
    597597}
    598598
    599 function pwg_query($query)
    600 {
    601   global $conf,$page,$debug,$t2;
    602 
    603   $start = get_moment();
    604   ($result = mysql_query($query)) or my_error($query, $conf['die_on_sql_error']);
    605 
    606   $time = get_moment() - $start;
    607 
    608   if (!isset($page['count_queries']))
    609   {
    610     $page['count_queries'] = 0;
    611     $page['queries_time'] = 0;
    612   }
    613 
    614   $page['count_queries']++;
    615   $page['queries_time']+= $time;
    616 
    617   if ($conf['show_queries'])
    618   {
    619     $output = '';
    620     $output.= '<pre>['.$page['count_queries'].'] ';
    621     $output.= "\n".$query;
    622     $output.= "\n".'(this query time : ';
    623     $output.= '<b>'.number_format($time, 3, '.', ' ').' s)</b>';
    624     $output.= "\n".'(total SQL time  : ';
    625     $output.= number_format($page['queries_time'], 3, '.', ' ').' s)';
    626     $output.= "\n".'(total time      : ';
    627     $output.= number_format( ($time+$start-$t2), 3, '.', ' ').' s)';
    628     if ( $result!=null and preg_match('/\s*SELECT\s+/i',$query) )
    629     {
    630       $output.= "\n".'(num rows        : ';
    631       $output.= mysql_num_rows($result).' )';
    632     }
    633     elseif ( $result!=null
    634       and preg_match('/\s*INSERT|UPDATE|REPLACE|DELETE\s+/i',$query) )
    635     {
    636       $output.= "\n".'(affected rows   : ';
    637       $output.= mysql_affected_rows().' )';
    638     }
    639     $output.= "</pre>\n";
    640 
    641     $debug .= $output;
    642   }
    643 
    644   return $result;
    645 }
    646 
    647599function pwg_debug( $string )
    648600{
     
    904856
    905857  return $thumbnail_title;
    906 }
    907 
    908 // my_error returns (or send to standard output) the message concerning the
    909 // error occured for the last mysql query.
    910 function my_error($header, $die)
    911 {
    912   $error = "[mysql error ".mysql_errno().'] '.mysql_error()."\n";
    913   $error .= $header;
    914 
    915   if ($die)
    916   {
    917     fatal_error($error);
    918   }
    919   echo("<pre>");
    920   trigger_error($error, E_USER_WARNING);
    921   echo("</pre>");
    922 }
    923 
    924 
    925 /**
    926  * creates an array based on a query, this function is a very common pattern
    927  * used here
    928  *
    929  * @param string $query
    930  * @param string $fieldname
    931  * @return array
    932  */
    933 function array_from_query($query, $fieldname)
    934 {
    935   $array = array();
    936 
    937   $result = pwg_query($query);
    938   while ($row = mysql_fetch_assoc($result))
    939   {
    940     array_push($array, $row[$fieldname]);
    941   }
    942 
    943   return $array;
    944858}
    945859
     
    11221036  WHERE '.$conf['user_fields']['id'].' = '.$conf['webmaster_id'].'
    11231037;';
    1124   list($email) = mysql_fetch_row(pwg_query($query));
     1038  list($email) = pwg_db_fetch_row(pwg_query($query));
    11251039
    11261040  return $email;
     
    11431057  $result = pwg_query($query);
    11441058
    1145   if ((mysql_num_rows($result) == 0) and !empty($condition))
     1059  if ((pwg_db_num_rows($result) == 0) and !empty($condition))
    11461060  {
    11471061    fatal_error('No configuration data');
    11481062  }
    11491063
    1150   while ($row = mysql_fetch_assoc($result))
     1064  while ($row = pwg_db_fetch_assoc($result))
    11511065  {
    11521066    $conf[ $row['param'] ] = isset($row['value']) ? $row['value'] : '';
     
    11931107
    11941108  $result = pwg_query($query);
    1195   while ($row = mysql_fetch_assoc($result))
     1109  while ($row = pwg_db_fetch_assoc($result))
    11961110  {
    11971111    $array[ $row[$keyname] ] = $row[$valuename];
     
    12141128  $array = array();
    12151129  $result = pwg_query($query);
    1216   while ($row = mysql_fetch_assoc($result))
     1130  while ($row = pwg_db_fetch_assoc($result))
    12171131  {
    12181132    $array[ $row[$keyname] ] = $row;
     
    15851499    // Use MySql date in order to standardize all recent "actions/queries"
    15861500    list($cache['get_icon']['sql_recent_date']) =
    1587       mysql_fetch_row(pwg_query('select SUBDATE(
     1501      pwg_db_fetch_row(pwg_query('select SUBDATE(
    15881502      CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)'));
    15891503  }
  • trunk/include/functions_category.inc.php

    r4265 r4325  
    102102  $cats = array();
    103103  $selected_category = isset($page['category']) ? $page['category'] : null;
    104   while ($row = mysql_fetch_assoc($result))
     104  while ($row = pwg_db_fetch_assoc($result))
    105105  {
    106106    $child_date_last = @$row['max_date_last']> @$row['date_last'];
     
    166166  WHERE id = '.$id.'
    167167;';
    168   $cat = mysql_fetch_assoc(pwg_query($query));
     168  $cat = pwg_db_fetch_assoc(pwg_query($query));
    169169  if (empty($cat))
    170170    return null;
     
    241241    $query.= ' FROM '.CATEGORIES_TABLE.' WHERE id = '.$category_id;
    242242    $query.= ';';
    243     $row = mysql_fetch_assoc( pwg_query( $query ) );
     243    $row = pwg_db_fetch_assoc( pwg_query( $query ) );
    244244    $uppercats = $row['uppercats'];
    245245  }
     
    252252  $query.= ';';
    253253  $result = pwg_query( $query );
    254   while( $row = mysql_fetch_assoc( $result ) )
     254  while( $row = pwg_db_fetch_assoc( $result ) )
    255255  {
    256256    $database_dirs[$row['id']] = $row['dir'];
     
    276276    AND c.id = '.$category_id.'
    277277;';
    278   $row = mysql_fetch_assoc(pwg_query($query));
     278  $row = pwg_db_fetch_assoc(pwg_query($query));
    279279  return $row['galleries_url'];
    280280}
     
    345345  if (!empty($result))
    346346  {
    347     while ($row = mysql_fetch_assoc($result))
     347    while ($row = pwg_db_fetch_assoc($result))
    348348    {
    349349      array_push($categories, $row);
     
    385385
    386386  $subcats = array();
    387   while ($row = mysql_fetch_assoc($result))
     387  while ($row = pwg_db_fetch_assoc($result))
    388388  {
    389389    array_push($subcats, $row['id']);
     
    534534LIMIT 1';
    535535
    536       $show_link = mysql_num_rows(pwg_query($query)) <> 0;
     536      $show_link = pwg_db_num_rows(pwg_query($query)) <> 0;
    537537    }
    538538  }
  • trunk/include/functions_comment.inc.php

    r4306 r4325  
    101101  FROM '.USERS_TABLE.'
    102102  WHERE '.$conf['user_fields']['username']." = '".addslashes($comm['author'])."'";
    103       $row = mysql_fetch_assoc( pwg_query( $query ) );
     103      $row = pwg_db_fetch_assoc( pwg_query( $query ) );
    104104      if ( $row['user_exists'] == 1 )
    105105      {
     
    139139  WHERE date > FROM_UNIXTIME('.$reference_date.')
    140140    AND author_id = '.$comm['author_id'];
    141     if ( mysql_num_rows( pwg_query( $query ) ) > 0 )
     141    if ( pwg_db_num_rows( pwg_query( $query ) ) > 0 )
    142142    {
    143143      array_push( $infos, l10n('comment_anti-flood') );
     
    169169    pwg_query($query);
    170170
    171     $comm['id'] = mysql_insert_id();
     171    $comm['id'] = pwg_db_insert_id();
    172172
    173173    if (($comment_action=='validate' and $conf['email_admin_on_comment']) or
     
    267267  WHERE date > FROM_UNIXTIME('.$reference_date.')
    268268    AND author_id = '.$comm['author_id'];
    269     if ( mysql_num_rows( pwg_query( $query ) ) > 0 )
     269    if ( pwg_db_num_rows( pwg_query( $query ) ) > 0 )
    270270    {
    271271      //?? array_push( $infos, l10n('comment_anti-flood') );
  • trunk/include/functions_mail.inc.php

    r4304 r4325  
    352352  if (!empty($datas))
    353353  {
    354     while ($admin = mysql_fetch_assoc($datas))
     354    while ($admin = pwg_db_fetch_assoc($datas))
    355355    {
    356356      if (!empty($admin['mail_address']))
     
    448448  $result = pwg_query($query);
    449449
    450   if (mysql_num_rows($result) > 0)
     450  if (pwg_db_num_rows($result) > 0)
    451451  {
    452452    $list = array();
    453     while ($row = mysql_fetch_assoc($result))
     453    while ($row = pwg_db_fetch_assoc($result))
    454454    {
    455455      $row['template_theme'] = $row['template'];
     
    477477      $result = pwg_query($query);
    478478
    479       if (mysql_num_rows($result) > 0)
     479      if (pwg_db_num_rows($result) > 0)
    480480      {
    481481        $Bcc = array();
    482         while ($row = mysql_fetch_assoc($result))
     482        while ($row = pwg_db_fetch_assoc($result))
    483483        {
    484484          if (!empty($row['mail_address']))
  • trunk/include/functions_notification.inc.php

    r4265 r4325  
    146146    $query = 'SELECT count(distinct '.$field_id.') as CountId
    147147'.$query;
    148     list($count) = mysql_fetch_row(pwg_query($query));
     148    list($count) = pwg_db_fetch_row(pwg_query($query));
    149149    return $count;
    150150
     
    179179    $infos = array();
    180180
    181     while ($row = mysql_fetch_assoc($result))
     181    while ($row = pwg_db_fetch_assoc($result))
    182182    {
    183183      array_push($infos, $row);
     
    449449  $result = pwg_query($query);
    450450  $dates = array();
    451   while ($row = mysql_fetch_assoc($result))
     451  while ($row = pwg_db_fetch_assoc($result))
    452452  {
    453453    array_push($dates, $row);
     
    469469      $dates[$i]['elements'] = array();
    470470      $result = pwg_query($query);
    471       while ($row = mysql_fetch_assoc($result))
     471      while ($row = pwg_db_fetch_assoc($result))
    472472      {
    473473        array_push($dates[$i]['elements'], $row);
     
    489489      $dates[$i]['categories'] = array();
    490490      $result = pwg_query($query);
    491       while ($row = mysql_fetch_assoc($result))
     491      while ($row = pwg_db_fetch_assoc($result))
    492492      {
    493493        array_push($dates[$i]['categories'], $row);
  • trunk/include/functions_plugins.inc.php

    r4265 r4325  
    239239  $result = pwg_query($query);
    240240  $plugins = array();
    241   while ($row = mysql_fetch_assoc($result))
     241  while ($row = pwg_db_fetch_assoc($result))
    242242  {
    243243    array_push($plugins, $row);
  • trunk/include/functions_rate.inc.php

    r3282 r4325  
    125125  WHERE element_id = '.$image_id.'
    126126;';
    127   $row = mysql_fetch_assoc(pwg_query($query));
     127  $row = pwg_db_fetch_assoc(pwg_query($query));
    128128  $query = '
    129129UPDATE '.IMAGES_TABLE.'
  • trunk/include/functions_search.inc.php

    r4265 r4325  
    4242  WHERE id = '.$search_id.'
    4343;';
    44   list($serialized_rules) = mysql_fetch_row(pwg_query($query));
     44  list($serialized_rules) = pwg_db_fetch_row(pwg_query($query));
    4545
    4646  return unserialize($serialized_rules);
     
    459459  $by_weights=array();
    460460  $result = pwg_query($query);
    461   while ($row = mysql_fetch_assoc($result))
     461  while ($row = pwg_db_fetch_assoc($result))
    462462  { // weight is important when sorting images by relevance
    463463    if ($row['weight'])
     
    490490  GROUP BY image_id';
    491491      $result = pwg_query($query);
    492       while ($row = mysql_fetch_assoc($result))
     492      while ($row = pwg_db_fetch_assoc($result))
    493493      { // weight is important when sorting images by relevance
    494494        $image_id=(int)$row['image_id'];
     
    511511    );
    512512  $result = pwg_query($query);
    513   while ($row = mysql_fetch_assoc($result))
     513  while ($row = pwg_db_fetch_assoc($result))
    514514  { // weight is important when sorting images by relevance
    515515    if ($row['nb_images']==0)
  • trunk/include/functions_session.inc.php

    r3282 r4325  
    122122  if ($result)
    123123  {
    124     $row = mysql_fetch_assoc($result);
     124    $row = pwg_db_fetch_assoc($result);
    125125    return $row['data'];
    126126  }
  • trunk/include/functions_tag.inc.php

    r3282 r4325  
    6464  $result = pwg_query($query);
    6565  $tags = array();
    66   while ($row = mysql_fetch_assoc($result))
     66  while ($row = pwg_db_fetch_assoc($result))
    6767  {
    6868    $counter = @$tag_counters[ $row['id'] ];
     
    8989  $result = pwg_query($query);
    9090  $tags = array();
    91   while ($row = mysql_fetch_assoc($result))
     91  while ($row = pwg_db_fetch_assoc($result))
    9292  {
    9393    array_push($tags, $row);
     
    250250  $result = pwg_query($query);
    251251  $tags = array();
    252   while($row = mysql_fetch_assoc($result))
     252  while($row = pwg_db_fetch_assoc($result))
    253253  {
    254254    array_push($tags, $row);
     
    312312  $result = pwg_query($query);
    313313  $tags = array();
    314   while ($row = mysql_fetch_assoc($result))
     314  while ($row = pwg_db_fetch_assoc($result))
    315315  {
    316316    array_push($tags, $row);
  • trunk/include/functions_user.inc.php

    r4304 r4325  
    5959'.(is_numeric($user_id) ? 'and '.$conf['user_fields']['id'].' != \''.$user_id.'\'' : '').'
    6060;';
    61     list($count) = mysql_fetch_row(pwg_query($query));
     61    list($count) = pwg_db_fetch_row(pwg_query($query));
    6262    if ($count != 0)
    6363    {
     
    111111  FROM '.USERS_TABLE.'
    112112;';
    113     list($next_id) = mysql_fetch_row(pwg_query($query));
     113    list($next_id) = pwg_db_fetch_row(pwg_query($query));
    114114
    115115    $insert =
    116116      array(
    117117        $conf['user_fields']['id'] => $next_id,
    118         $conf['user_fields']['username'] => mysql_real_escape_string($login),
     118        $conf['user_fields']['username'] => pwg_db_real_escape_string($login),
    119119        $conf['user_fields']['password'] => $conf['pass_convert']($password),
    120120        $conf['user_fields']['email'] => $mail_address
     
    135135
    136136      $inserts = array();
    137       while ($row = mysql_fetch_assoc($result))
     137      while ($row = pwg_db_fetch_assoc($result))
    138138      {
    139139        array_push
     
    250250  WHERE '.$conf['user_fields']['id'].' = \''.$user_id.'\'';
    251251
    252   $row = mysql_fetch_assoc(pwg_query($query));
     252  $row = pwg_db_fetch_assoc(pwg_query($query));
    253253
    254254  while (true)
     
    260260  WHERE ui.user_id = \''.$user_id.'\'';
    261261    $result = pwg_query($query);
    262     if (mysql_num_rows($result) > 0)
     262    if (pwg_db_num_rows($result) > 0)
    263263    {
    264264      break;
     
    270270  }
    271271
    272   $row = array_merge($row, mysql_fetch_assoc($result));
     272  $row = array_merge($row, pwg_db_fetch_assoc($result));
    273273
    274274  foreach ($row as $key => $value)
     
    325325  WHERE category_id NOT IN ('.$userdata['forbidden_categories'].')
    326326    AND image_id '.$userdata['image_access_type'].' ('.$userdata['image_access_list'].')';
    327       list($userdata['nb_total_images']) = mysql_fetch_row(pwg_query($query));
     327      list($userdata['nb_total_images']) = pwg_db_fetch_row(pwg_query($query));
    328328
    329329
     
    429429  $result = pwg_query($query);
    430430  $authorizeds = array();
    431   while ($row = mysql_fetch_assoc($result))
     431  while ($row = pwg_db_fetch_assoc($result))
    432432  {
    433433    array_push($authorizeds, $row['image_id']);
     
    441441  $result = pwg_query($query);
    442442  $favorites = array();
    443   while ($row = mysql_fetch_assoc($result))
     443  while ($row = pwg_db_fetch_assoc($result))
    444444  {
    445445    array_push($favorites, $row['image_id']);
     
    482482;';
    483483  $result = pwg_query($query);
    484   while ($row = mysql_fetch_assoc($result))
     484  while ($row = pwg_db_fetch_assoc($result))
    485485  {
    486486    array_push($private_array, $row['id']);
     
    524524;';
    525525    $result = pwg_query($query);
    526     while ($row = mysql_fetch_assoc($result))
     526    while ($row = pwg_db_fetch_assoc($result))
    527527    {
    528528      array_push($forbidden_array, $row['id']);
     
    648648
    649649  $cats = array();
    650   while ($row = mysql_fetch_assoc($result))
     650  while ($row = pwg_db_fetch_assoc($result))
    651651  {
    652652    $row['user_id'] = $userdata['id'];
     
    693693  global $conf;
    694694
    695   $username = mysql_real_escape_string($username);
     695  $username = pwg_db_real_escape_string($username);
    696696
    697697  $query = '
     
    702702  $result = pwg_query($query);
    703703
    704   if (mysql_num_rows($result) == 0)
     704  if (pwg_db_num_rows($result) == 0)
    705705  {
    706706    return false;
     
    708708  else
    709709  {
    710     list($user_id) = mysql_fetch_row($result);
     710    list($user_id) = pwg_db_fetch_row($result);
    711711    return $user_id;
    712712  }
     
    728728  WHERE id = \''.$key.'\'
    729729;';
    730     list($count) = mysql_fetch_row(pwg_query($query));
     730    list($count) = pwg_db_fetch_row(pwg_query($query));
    731731    if (0 == $count)
    732732    {
     
    751751
    752752    $result = pwg_query($query);
    753     $cache['default_user'] = mysql_fetch_assoc($result);
     753    $cache['default_user'] = pwg_db_fetch_assoc($result);
    754754
    755755    if ($cache['default_user'] !== false)
     
    866866  {
    867867    $inserts = array();
    868     list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
     868    list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
    869869
    870870    $default_user = get_default_user_info(false);
     
    931931WHERE '.$conf['user_fields']['id'].' = '.$user_id;
    932932  $result = pwg_query($query);
    933   if (mysql_num_rows($result) > 0)
    934   {
    935     $row = mysql_fetch_assoc($result);
     933  if (pwg_db_num_rows($result) > 0)
     934  {
     935    $row = pwg_db_fetch_assoc($result);
    936936    $username = stripslashes($row['username']);
    937937    $data = $time.stripslashes($row['username']).$row['password'];
     
    10421042  WHERE '.$conf['user_fields']['username'].' = \''.mysql_real_escape_string($username).'\'
    10431043;';
    1044   $row = mysql_fetch_assoc(pwg_query($query));
     1044  $row = pwg_db_fetch_assoc(pwg_query($query));
    10451045  if ($row['password'] == $conf['pass_convert']($password))
    10461046  {
  • trunk/include/picture_comment.inc.php

    r4304 r4325  
    9494  FROM '.COMMENTS_TABLE.'
    9595  WHERE image_id='.$page['image_id']." AND validated = 'true'";
    96   $row = mysql_fetch_assoc( pwg_query( $query ) );
     96  $row = pwg_db_fetch_assoc( pwg_query( $query ) );
    9797
    9898  // navigation bar creation
     
    141141    $result = pwg_query( $query );
    142142
    143     while ($row = mysql_fetch_assoc($result))
     143    while ($row = pwg_db_fetch_assoc($result))
    144144    {
    145145      if (!empty($row['author']))
  • trunk/include/picture_rate.inc.php

    r4265 r4325  
    3838  WHERE element_id = '.$picture['current']['id'].'
    3939;';
    40     $row = mysql_fetch_assoc(pwg_query($query));
     40    $row = pwg_db_fetch_assoc(pwg_query($query));
    4141  }
    4242  else
     
    6868
    6969      $result = pwg_query($query);
    70       if (mysql_num_rows($result) > 0)
     70      if (pwg_db_num_rows($result) > 0)
    7171      {
    72         $row = mysql_fetch_assoc($result);
     72        $row = pwg_db_fetch_assoc($result);
    7373        $user_rate = $row['rate'];
    7474      }
  • trunk/include/ws_functions.inc.php

    r4304 r4325  
    257257  $result = pwg_query($query);
    258258  $cats = array();
    259   while ($row = mysql_fetch_assoc($result))
     259  while ($row = pwg_db_fetch_assoc($result))
    260260  {
    261261    $row['id'] = (int)$row['id'];
     
    296296
    297297    $result = pwg_query($query);
    298     while ($row = mysql_fetch_assoc($result))
     298    while ($row = pwg_db_fetch_assoc($result))
    299299    {
    300300      $image = array();
     
    406406
    407407  $cats = array();
    408   while ($row = mysql_fetch_assoc($result))
     408  while ($row = pwg_db_fetch_assoc($result))
    409409  {
    410410    $row['url'] = make_index_url(
     
    472472  $cats = array();
    473473
    474   while ($row = mysql_fetch_assoc($result))
     474  while ($row = pwg_db_fetch_assoc($result))
    475475  {
    476476    $id = $row['id'];
     
    518518      ' AND'
    519519    );
    520   if ( !mysql_num_rows( pwg_query( $query ) ) )
     520  if ( !pwg_db_num_rows( pwg_query( $query ) ) )
    521521  {
    522522    return new PwgError(WS_ERR_INVALID_PARAM, "Invalid image_id");
     
    578578LIMIT 1';
    579579
    580   $image_row = mysql_fetch_assoc(pwg_query($query));
     580  $image_row = pwg_db_fetch_assoc(pwg_query($query));
    581581  if ($image_row==null)
    582582  {
     
    599599  $is_commentable = false;
    600600  $related_categories = array();
    601   while ($row = mysql_fetch_assoc($result))
     601  while ($row = pwg_db_fetch_assoc($result))
    602602  {
    603603    if ($row['commentable']=='true')
     
    656656  WHERE element_id = '.$image_row['id'].'
    657657;';
    658   $rating = mysql_fetch_assoc(pwg_query($query));
     658  $rating = pwg_db_fetch_assoc(pwg_query($query));
    659659  $rating['count'] = (int)$rating['count'];
    660660
     
    687687
    688688    $result = pwg_query($query);
    689     while ($row = mysql_fetch_assoc($result))
     689    while ($row = pwg_db_fetch_assoc($result))
    690690    {
    691691      $row['id']=(int)$row['id'];
     
    758758    ).'
    759759    LIMIT 1';
    760   if ( mysql_num_rows( pwg_query($query) )==0 )
     760  if ( pwg_db_num_rows( pwg_query($query) )==0 )
    761761  {
    762762    return new PwgError(404, "Invalid image_id or access denied" );
     
    814814    $image_ids = array_flip($image_ids);
    815815    $result = pwg_query($query);
    816     while ($row = mysql_fetch_assoc($result))
     816    while ($row = pwg_db_fetch_assoc($result))
    817817    {
    818818      $image = array();
     
    871871  WHERE id IN ('.implode(',',$params['image_id']).')';
    872872  $result = pwg_query($query);
    873   $affected_rows = mysql_affected_rows();
     873  $affected_rows = pwg_db_affected_rows();
    874874  if ($affected_rows)
    875875  {
     
    10081008  WHERE md5sum = \''.$params['original_sum'].'\'
    10091009;';
    1010   list($counter) = mysql_fetch_row(pwg_query($query));
     1010  list($counter) = pwg_db_fetch_row(pwg_query($query));
    10111011  if ($counter != 0) {
    10121012    return new PwgError(500, 'file already exists');
     
    10141014
    10151015  // current date
    1016   list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
     1016  list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
    10171017  list($year, $month, $day) = preg_split('/[^\d]/', $dbnow, 4);
    10181018
     
    12001200    );
    12011201
    1202   $image_id = mysql_insert_id();
     1202  $image_id = pwg_db_insert_id();
    12031203
    12041204  // let's add links between the image and the categories
     
    13591359  GROUP BY image_id';
    13601360      $result = pwg_query($query);
    1361       while ( $row=mysql_fetch_assoc($result) )
     1361      while ( $row=pwg_db_fetch_assoc($result) )
    13621362      {
    13631363        $row['image_id'] = (int)$row['image_id'];
     
    14021402
    14031403    $result = pwg_query($query);
    1404     while ($row = mysql_fetch_assoc($result))
     1404    while ($row = pwg_db_fetch_assoc($result))
    14051405    {
    14061406      $image = array();
     
    15731573;';
    15741574
    1575   $image_row = mysql_fetch_assoc(pwg_query($query));
     1575  $image_row = pwg_db_fetch_assoc(pwg_query($query));
    15761576  if ($image_row == null)
    15771577  {
Note: See TracChangeset for help on using the changeset viewer.