aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authornikrou <nikrou@piwigo.org>2009-11-20 14:17:04 +0000
committernikrou <nikrou@piwigo.org>2009-11-20 14:17:04 +0000
commit924dd262ec3778277cf1efedee92fa5dd4fb2d32 (patch)
tree05176413aa5b4762dd72477099644c732389f971 /include
parentc020cd0d7cb7710a6ffe04fc8b6d6ccfecb2c466 (diff)
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 { }. git-svn-id: http://piwigo.org/svn/trunk@4325 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include')
-rw-r--r--include/calendar_monthly.class.php8
-rw-r--r--include/category_cats.inc.php14
-rw-r--r--include/category_default.inc.php2
-rw-r--r--include/common.inc.php20
-rw-r--r--include/dblayer/functions_mysql.inc.php463
-rw-r--r--include/functions.inc.php102
-rw-r--r--include/functions_category.inc.php16
-rw-r--r--include/functions_comment.inc.php8
-rw-r--r--include/functions_mail.inc.php10
-rw-r--r--include/functions_notification.inc.php10
-rw-r--r--include/functions_plugins.inc.php2
-rw-r--r--include/functions_rate.inc.php2
-rw-r--r--include/functions_search.inc.php8
-rw-r--r--include/functions_session.inc.php2
-rw-r--r--include/functions_tag.inc.php8
-rw-r--r--include/functions_user.inc.php44
-rw-r--r--include/picture_comment.inc.php4
-rw-r--r--include/picture_rate.inc.php6
-rw-r--r--include/ws_functions.inc.php36
19 files changed, 566 insertions, 199 deletions
diff --git a/include/calendar_monthly.class.php b/include/calendar_monthly.class.php
index b4df9f5f8..e78824617 100644
--- a/include/calendar_monthly.class.php
+++ b/include/calendar_monthly.class.php
@@ -231,7 +231,7 @@ function build_global_calendar(&$tpl_var)
$result = pwg_query($query);
$items=array();
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$y = substr($row['period'], 0, 4);
$m = (int)substr($row['period'], 4, 2);
@@ -283,7 +283,7 @@ function build_year_calendar(&$tpl_var)
$result = pwg_query($query);
$items=array();
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$m = (int)substr($row['period'], 0, 2);
$d = substr($row['period'], 2, 2);
@@ -333,7 +333,7 @@ function build_month_calendar(&$tpl_var)
$items=array();
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$d = (int)$row['period'];
$items[$d] = array('nb_images'=>$row['count']);
@@ -351,7 +351,7 @@ SELECT id, file,tn_ext,path, width, height, DAYOFWEEK('.$this->date_field.')-1 a
LIMIT 0,1';
unset ( $page['chronology_date'][CDAY] );
- $row = mysql_fetch_assoc(pwg_query($query));
+ $row = pwg_db_fetch_assoc(pwg_query($query));
$items[$day]['tn_url'] = get_thumbnail_url($row);
$items[$day]['file'] = $row['file'];
$items[$day]['path'] = $row['path'];
diff --git a/include/category_cats.inc.php b/include/category_cats.inc.php
index 1cd7c0407..0d35d4a85 100644
--- a/include/category_cats.inc.php
+++ b/include/category_cats.inc.php
@@ -75,7 +75,7 @@ $categories = array();
$category_ids = array();
$image_ids = array();
-while ($row = mysql_fetch_assoc($result))
+while ($row = pwg_db_fetch_assoc($result))
{
$row['is_child_date_last'] = @$row['max_date_last']>@$row['date_last'];
@@ -108,9 +108,9 @@ SELECT image_id
LIMIT 0,1
;';
$subresult = pwg_query($query);
- if (mysql_num_rows($subresult) > 0)
+ if (pwg_db_num_rows($subresult) > 0)
{
- list($image_id) = mysql_fetch_row($subresult);
+ list($image_id) = pwg_db_fetch_row($subresult);
}
}
}
@@ -136,9 +136,9 @@ SELECT image_id
LIMIT 0,1
;';
$subresult = pwg_query($query);
- if (mysql_num_rows($subresult) > 0)
+ if (pwg_db_num_rows($subresult) > 0)
{
- list($image_id) = mysql_fetch_row($subresult);
+ list($image_id) = pwg_db_fetch_row($subresult);
}
}
}
@@ -178,7 +178,7 @@ SELECT
GROUP BY category_id
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$dates_of_category[ $row['category_id'] ] = array(
'from' => $row['date_creation_min'],
@@ -202,7 +202,7 @@ SELECT id, path, tn_ext
WHERE id IN ('.implode(',', $image_ids).')
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$thumbnail_src_of[$row['id']] = get_thumbnail_url($row);
}
diff --git a/include/category_default.inc.php b/include/category_default.inc.php
index ae24adec1..796a88989 100644
--- a/include/category_default.inc.php
+++ b/include/category_default.inc.php
@@ -45,7 +45,7 @@ SELECT *
WHERE id IN ('.implode(',', $selection).')
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$row['rank'] = $rank_of[ $row['id'] ];
diff --git a/include/common.inc.php b/include/common.inc.php
index a0ec209ef..9fdc014d5 100644
--- a/include/common.inc.php
+++ b/include/common.inc.php
@@ -92,6 +92,7 @@ foreach( array(
include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
@include(PHPWG_ROOT_PATH. 'include/config_local.inc.php');
+include(PHPWG_ROOT_PATH .'include/dblayer/functions_mysql.inc.php');
if(isset($conf['show_php_errors']) && !empty($conf['show_php_errors']))
{
@@ -104,22 +105,11 @@ include(PHPWG_ROOT_PATH . 'include/functions.inc.php');
include( PHPWG_ROOT_PATH .'include/template.class.php');
// Database connection
-@mysql_connect( $conf['db_host'], $conf['db_user'], $conf['db_password'] ) or my_error( 'mysql_connect', true );
-@mysql_select_db( $conf['db_base'] ) or my_error( 'mysql_select_db', true );
+$pwg_db_link = pwg_db_connect($conf['db_host'], $conf['db_user'],
+ $conf['db_password'], $conf['db_base'])
+ or my_error('pwg_db_connect', true);
-defined('PWG_CHARSET') and defined('DB_CHARSET')
- or fatal_error('PWG_CHARSET and/or DB_CHARSET is not defined');
-if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') )
-{
- if (DB_CHARSET!='')
- {
- pwg_query('SET NAMES "'.DB_CHARSET.'"');
- }
-}
-elseif ( strtolower(PWG_CHARSET)!='iso-8859-1' )
-{
- fatal_error('PWG supports only iso-8859-1 charset on MySql version '.mysql_get_server_info());
-}
+pwg_db_check_charset();
load_conf_from_db();
load_plugins();
diff --git a/include/dblayer/functions_mysql.inc.php b/include/dblayer/functions_mysql.inc.php
new file mode 100644
index 000000000..23d232675
--- /dev/null
+++ b/include/dblayer/functions_mysql.inc.php
@@ -0,0 +1,463 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008-2009 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify |
+// | it under the terms of the GNU General Public License as published by |
+// | the Free Software Foundation |
+// | |
+// | This program is distributed in the hope that it will be useful, but |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+// | General Public License for more details. |
+// | |
+// | You should have received a copy of the GNU General Public License |
+// | along with this program; if not, write to the Free Software |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA. |
+// +-----------------------------------------------------------------------+
+
+/**
+ *
+ * simple functions
+ *
+ */
+
+function pwg_db_connect($host, $user, $password, $database)
+{
+ $link = mysql_connect($host, $user, $password) or my_error('mysql_connect', true);
+ mysql_select_db($database, $link) or my_error('mysql_select_db', true);
+
+ return $link;
+}
+
+function pwg_db_check_charset()
+{
+ defined('PWG_CHARSET') and defined('DB_CHARSET')
+ or fatal_error('PWG_CHARSET and/or DB_CHARSET is not defined');
+ if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') )
+ {
+ if (DB_CHARSET!='')
+ {
+ pwg_query('SET NAMES "'.DB_CHARSET.'"');
+ }
+ }
+ elseif ( strtolower(PWG_CHARSET)!='iso-8859-1' )
+ {
+ fatal_error('PWG supports only iso-8859-1 charset on MySql version '.mysql_get_server_info());
+ }
+}
+
+function pwg_get_db_version()
+{
+ list($mysql_version) = pwg_db_fetch_row(pwg_query('SELECT VERSION();'));
+
+ return $mysql_version;
+}
+
+function pwg_query($query)
+{
+ global $conf,$page,$debug,$t2;
+
+ $start = get_moment();
+ ($result = mysql_query($query)) or my_error($query, $conf['die_on_sql_error']);
+
+ $time = get_moment() - $start;
+
+ if (!isset($page['count_queries']))
+ {
+ $page['count_queries'] = 0;
+ $page['queries_time'] = 0;
+ }
+
+ $page['count_queries']++;
+ $page['queries_time']+= $time;
+
+ if ($conf['show_queries'])
+ {
+ $output = '';
+ $output.= '<pre>['.$page['count_queries'].'] ';
+ $output.= "\n".$query;
+ $output.= "\n".'(this query time : ';
+ $output.= '<b>'.number_format($time, 3, '.', ' ').' s)</b>';
+ $output.= "\n".'(total SQL time : ';
+ $output.= number_format($page['queries_time'], 3, '.', ' ').' s)';
+ $output.= "\n".'(total time : ';
+ $output.= number_format( ($time+$start-$t2), 3, '.', ' ').' s)';
+ if ( $result!=null and preg_match('/\s*SELECT\s+/i',$query) )
+ {
+ $output.= "\n".'(num rows : ';
+ $output.= mysql_num_rows($result).' )';
+ }
+ elseif ( $result!=null
+ and preg_match('/\s*INSERT|UPDATE|REPLACE|DELETE\s+/i',$query) )
+ {
+ $output.= "\n".'(affected rows : ';
+ $output.= mysql_affected_rows().' )';
+ }
+ $output.= "</pre>\n";
+
+ $debug .= $output;
+ }
+
+ return $result;
+}
+
+function pwg_db_changes($result)
+{
+ return mysql_affected_rows($result);
+}
+
+function pwg_db_num_rows($result)
+{
+ return mysql_num_rows($result);
+}
+
+function pwg_db_fetch_assoc($result)
+{
+ return mysql_fetch_assoc($result);
+}
+
+function pwg_db_fetch_row($result)
+{
+ return mysql_fetch_row($result);
+}
+
+function pwg_db_fetch_object($result)
+{
+ return mysql_fetch_object($result);
+}
+
+function pwg_free_result($result)
+{
+ return mysql_free_result($result);
+}
+
+function pwg_db_real_escape_string($s)
+{
+ return mysql_real_escape_string($s);
+}
+
+function pwg_db_insert_id()
+{
+ return mysql_insert_id();
+}
+
+/**
+ *
+ * complex functions
+ *
+ */
+
+/**
+ * creates an array based on a query, this function is a very common pattern
+ * used here
+ *
+ * @param string $query
+ * @param string $fieldname
+ * @return array
+ */
+function array_from_query($query, $fieldname)
+{
+ $array = array();
+
+ $result = pwg_query($query);
+ while ($row = mysql_fetch_assoc($result))
+ {
+ array_push($array, $row[$fieldname]);
+ }
+
+ return $array;
+}
+
+define('MASS_UPDATES_SKIP_EMPTY', 1);
+/**
+ * updates multiple lines in a table
+ *
+ * @param string table_name
+ * @param array dbfields
+ * @param array datas
+ * @param int flags - if MASS_UPDATES_SKIP_EMPTY - empty values do not overwrite existing ones
+ * @return void
+ */
+function mass_updates($tablename, $dbfields, $datas, $flags=0)
+{
+ if (count($datas) == 0)
+ return;
+ // depending on the MySQL version, we use the multi table update or N update queries
+ if (count($datas) < 10 or version_compare(mysql_get_server_info(), '4.0.4') < 0)
+ { // MySQL is prior to version 4.0.4, multi table update feature is not available
+ foreach ($datas as $data)
+ {
+ $query = '
+UPDATE '.$tablename.'
+ SET ';
+ $is_first = true;
+ foreach ($dbfields['update'] as $key)
+ {
+ $separator = $is_first ? '' : ",\n ";
+
+ if (isset($data[$key]) and $data[$key] != '')
+ {
+ $query.= $separator.$key.' = \''.$data[$key].'\'';
+ }
+ else
+ {
+ if ($flags & MASS_UPDATES_SKIP_EMPTY )
+ continue; // next field
+ $query.= "$separator$key = NULL";
+ }
+ $is_first = false;
+ }
+ if (!$is_first)
+ {// only if one field at least updated
+ $query.= '
+ WHERE ';
+ $is_first = true;
+ foreach ($dbfields['primary'] as $key)
+ {
+ if (!$is_first)
+ {
+ $query.= ' AND ';
+ }
+ if ( isset($data[$key]) )
+ {
+ $query.= $key.' = \''.$data[$key].'\'';
+ }
+ else
+ {
+ $query.= $key.' IS NULL';
+ }
+ $is_first = false;
+ }
+ pwg_query($query);
+ }
+ } // foreach update
+ } // if mysql_ver or count<X
+ else
+ {
+ // creation of the temporary table
+ $query = '
+SHOW FULL COLUMNS FROM '.$tablename;
+ $result = pwg_query($query);
+ $columns = array();
+ $all_fields = array_merge($dbfields['primary'], $dbfields['update']);
+ while ($row = pwg_db_fetch_assoc($result))
+ {
+ if (in_array($row['Field'], $all_fields))
+ {
+ $column = $row['Field'];
+ $column.= ' '.$row['Type'];
+
+ $nullable = true;
+ if (!isset($row['Null']) or $row['Null'] == '' or $row['Null']=='NO')
+ {
+ $column.= ' NOT NULL';
+ $nullable = false;
+ }
+ if (isset($row['Default']))
+ {
+ $column.= " default '".$row['Default']."'";
+ }
+ elseif ($nullable)
+ {
+ $column.= " default NULL";
+ }
+ if (isset($row['Collation']) and $row['Collation'] != 'NULL')
+ {
+ $column.= " collate '".$row['Collation']."'";
+ }
+ array_push($columns, $column);
+ }
+ }
+
+ $temporary_tablename = $tablename.'_'.micro_seconds();
+
+ $query = '
+CREATE TABLE '.$temporary_tablename.'
+(
+ '.implode(",\n ", $columns).',
+ UNIQUE KEY the_key ('.implode(',', $dbfields['primary']).')
+)';
+
+ pwg_query($query);
+ mass_inserts($temporary_tablename, $all_fields, $datas);
+ if ( $flags & MASS_UPDATES_SKIP_EMPTY )
+ $func_set = create_function('$s', 'return "t1.$s = IFNULL(t2.$s, t1.$s)";');
+ else
+ $func_set = create_function('$s', 'return "t1.$s = t2.$s";');
+
+ // update of images table by joining with temporary table
+ $query = '
+UPDATE '.$tablename.' AS t1, '.$temporary_tablename.' AS t2
+ SET '.
+ implode(
+ "\n , ",
+ array_map($func_set,$dbfields['update'])
+ ).'
+ WHERE '.
+ implode(
+ "\n AND ",
+ array_map(
+ create_function('$s', 'return "t1.$s = t2.$s";'),
+ $dbfields['primary']
+ )
+ );
+ pwg_query($query);
+ $query = '
+DROP TABLE '.$temporary_tablename;
+ pwg_query($query);
+ }
+}
+
+
+/**
+ * inserts multiple lines in a table
+ *
+ * @param string table_name
+ * @param array dbfields
+ * @param array inserts
+ * @return void
+ */
+function mass_inserts($table_name, $dbfields, $datas)
+{
+ if (count($datas) != 0)
+ {
+ $first = true;
+
+ $query = 'SHOW VARIABLES LIKE \'max_allowed_packet\'';
+ list(, $packet_size) = pwg_db_fetch_row(pwg_query($query));
+ $packet_size = $packet_size - 2000; // The last list of values MUST not exceed 2000 character*/
+ $query = '';
+
+ foreach ($datas as $insert)
+ {
+ if (strlen($query) >= $packet_size)
+ {
+ pwg_query($query);
+ $first = true;
+ }
+
+ if ($first)
+ {
+ $query = '
+INSERT INTO '.$table_name.'
+ ('.implode(',', $dbfields).')
+ VALUES';
+ $first = false;
+ }
+ else
+ {
+ $query .= '
+ , ';
+ }
+
+ $query .= '(';
+ foreach ($dbfields as $field_id => $dbfield)
+ {
+ if ($field_id > 0)
+ {
+ $query .= ',';
+ }
+
+ if (!isset($insert[$dbfield]) or $insert[$dbfield] === '')
+ {
+ $query .= 'NULL';
+ }
+ else
+ {
+ $query .= "'".$insert[$dbfield]."'";
+ }
+ }
+ $query .= ')';
+ }
+ Log::getInstance()->debug($query);
+ pwg_query($query);
+ }
+}
+
+/**
+ * Do maintenance on all PWG tables
+ *
+ * @return none
+ */
+function do_maintenance_all_tables()
+{
+ global $prefixeTable, $page;
+
+ $all_tables = array();
+
+ // List all tables
+ $query = 'SHOW TABLES LIKE \''.$prefixeTable.'%\'';
+ $result = pwg_query($query);
+ while ($row = pwg_db_fetch_assoc($result))
+ {
+ array_push($all_tables, $row[0]);
+ }
+
+ // Repair all tables
+ $query = 'REPAIR TABLE '.implode(', ', $all_tables);
+ $mysql_rc = pwg_query($query);
+
+ // Re-Order all tables
+ foreach ($all_tables as $table_name)
+ {
+ $all_primary_key = array();
+
+ $query = 'DESC '.$table_name.';';
+ $result = pwg_query($query);
+ while ($row = pwg_db_fetch_assoc($result))
+ {
+ if ($row['Key'] == 'PRI')
+ {
+ array_push($all_primary_key, $row['Field']);
+ }
+ }
+
+ if (count($all_primary_key) != 0)
+ {
+ $query = 'ALTER TABLE '.$table_name.' ORDER BY '.implode(', ', $all_primary_key).';';
+ $mysql_rc = $mysql_rc && pwg_query($query);
+ }
+ }
+
+ // Optimize all tables
+ $query = 'OPTIMIZE TABLE '.implode(', ', $all_tables);
+ $mysql_rc = $mysql_rc && pwg_query($query);
+ if ($mysql_rc)
+ {
+ array_push(
+ $page['infos'],
+ l10n('Optimizations completed')
+ );
+ }
+ else
+ {
+ array_push(
+ $page['errors'],
+ l10n('Optimizations errors')
+ );
+ }
+}
+
+// my_error returns (or send to standard output) the message concerning the
+// error occured for the last mysql query.
+function my_error($header, $die)
+{
+ $error = "[mysql error ".mysql_errno().'] '.mysql_error()."\n";
+ $error .= $header;
+
+ if ($die)
+ {
+ fatal_error($error);
+ }
+ echo("<pre>");
+ trigger_error($error, E_USER_WARNING);
+ echo("</pre>");
+}
+
+?> \ No newline at end of file
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 7353eda6a..a31c85f13 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -44,7 +44,7 @@ function get_enums($table, $field)
// retrieving the properties of the table. Each line represents a field :
// columns are 'Field', 'Type'
$result = pwg_query('desc '.$table);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
// we are only interested in the the field given in parameter for the
// function
@@ -59,7 +59,7 @@ function get_enums($table, $field)
}
}
}
- mysql_free_result($result);
+ pwg_db_free_result($result);
return $options;
}
@@ -596,54 +596,6 @@ function format_date($date, $show_time = false)
return $formated_date;
}
-function pwg_query($query)
-{
- global $conf,$page,$debug,$t2;
-
- $start = get_moment();
- ($result = mysql_query($query)) or my_error($query, $conf['die_on_sql_error']);
-
- $time = get_moment() - $start;
-
- if (!isset($page['count_queries']))
- {
- $page['count_queries'] = 0;
- $page['queries_time'] = 0;
- }
-
- $page['count_queries']++;
- $page['queries_time']+= $time;
-
- if ($conf['show_queries'])
- {
- $output = '';
- $output.= '<pre>['.$page['count_queries'].'] ';
- $output.= "\n".$query;
- $output.= "\n".'(this query time : ';
- $output.= '<b>'.number_format($time, 3, '.', ' ').' s)</b>';
- $output.= "\n".'(total SQL time : ';
- $output.= number_format($page['queries_time'], 3, '.', ' ').' s)';
- $output.= "\n".'(total time : ';
- $output.= number_format( ($time+$start-$t2), 3, '.', ' ').' s)';
- if ( $result!=null and preg_match('/\s*SELECT\s+/i',$query) )
- {
- $output.= "\n".'(num rows : ';
- $output.= mysql_num_rows($result).' )';
- }
- elseif ( $result!=null
- and preg_match('/\s*INSERT|UPDATE|REPLACE|DELETE\s+/i',$query) )
- {
- $output.= "\n".'(affected rows : ';
- $output.= mysql_affected_rows().' )';
- }
- $output.= "</pre>\n";
-
- $debug .= $output;
- }
-
- return $result;
-}
-
function pwg_debug( $string )
{
global $debug,$t2,$page;
@@ -905,44 +857,6 @@ function get_thumbnail_title($element_info)
return $thumbnail_title;
}
-// my_error returns (or send to standard output) the message concerning the
-// error occured for the last mysql query.
-function my_error($header, $die)
-{
- $error = "[mysql error ".mysql_errno().'] '.mysql_error()."\n";
- $error .= $header;
-
- if ($die)
- {
- fatal_error($error);
- }
- echo("<pre>");
- trigger_error($error, E_USER_WARNING);
- echo("</pre>");
-}
-
-
-/**
- * creates an array based on a query, this function is a very common pattern
- * used here
- *
- * @param string $query
- * @param string $fieldname
- * @return array
- */
-function array_from_query($query, $fieldname)
-{
- $array = array();
-
- $result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
- {
- array_push($array, $row[$fieldname]);
- }
-
- return $array;
-}
-
/**
* fill the current user caddie with given elements, if not already in
* caddie
@@ -1121,7 +1035,7 @@ SELECT '.$conf['user_fields']['email'].'
FROM '.USERS_TABLE.'
WHERE '.$conf['user_fields']['id'].' = '.$conf['webmaster_id'].'
;';
- list($email) = mysql_fetch_row(pwg_query($query));
+ list($email) = pwg_db_fetch_row(pwg_query($query));
return $email;
}
@@ -1142,12 +1056,12 @@ SELECT param, value
;';
$result = pwg_query($query);
- if ((mysql_num_rows($result) == 0) and !empty($condition))
+ if ((pwg_db_num_rows($result) == 0) and !empty($condition))
{
fatal_error('No configuration data');
}
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$conf[ $row['param'] ] = isset($row['value']) ? $row['value'] : '';
@@ -1192,7 +1106,7 @@ function simple_hash_from_query($query, $keyname, $valuename)
$array = array();
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$array[ $row[$keyname] ] = $row[$valuename];
}
@@ -1213,7 +1127,7 @@ function hash_from_query($query, $keyname)
{
$array = array();
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$array[ $row[$keyname] ] = $row;
}
@@ -1584,7 +1498,7 @@ function get_icon($date, $is_child_date = false)
{
// Use MySql date in order to standardize all recent "actions/queries"
list($cache['get_icon']['sql_recent_date']) =
- mysql_fetch_row(pwg_query('select SUBDATE(
+ pwg_db_fetch_row(pwg_query('select SUBDATE(
CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)'));
}
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index dd2707b10..fb981fcbd 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -101,7 +101,7 @@ WHERE '.$where.'
$result = pwg_query($query);
$cats = array();
$selected_category = isset($page['category']) ? $page['category'] : null;
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$child_date_last = @$row['max_date_last']> @$row['date_last'];
$row = array_merge($row,
@@ -165,7 +165,7 @@ SELECT *
FROM '.CATEGORIES_TABLE.'
WHERE id = '.$id.'
;';
- $cat = mysql_fetch_assoc(pwg_query($query));
+ $cat = pwg_db_fetch_assoc(pwg_query($query));
if (empty($cat))
return null;
@@ -240,7 +240,7 @@ function get_local_dir( $category_id )
$query = 'SELECT uppercats';
$query.= ' FROM '.CATEGORIES_TABLE.' WHERE id = '.$category_id;
$query.= ';';
- $row = mysql_fetch_assoc( pwg_query( $query ) );
+ $row = pwg_db_fetch_assoc( pwg_query( $query ) );
$uppercats = $row['uppercats'];
}
@@ -251,7 +251,7 @@ function get_local_dir( $category_id )
$query.= ' FROM '.CATEGORIES_TABLE.' WHERE id IN ('.$uppercats.')';
$query.= ';';
$result = pwg_query( $query );
- while( $row = mysql_fetch_assoc( $result ) )
+ while( $row = pwg_db_fetch_assoc( $result ) )
{
$database_dirs[$row['id']] = $row['dir'];
}
@@ -275,7 +275,7 @@ SELECT galleries_url
WHERE s.id = c.site_id
AND c.id = '.$category_id.'
;';
- $row = mysql_fetch_assoc(pwg_query($query));
+ $row = pwg_db_fetch_assoc(pwg_query($query));
return $row['galleries_url'];
}
@@ -344,7 +344,7 @@ function display_select_cat_wrapper($query, $selecteds, $blockname,
$categories = array();
if (!empty($result))
{
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push($categories, $row);
}
@@ -384,7 +384,7 @@ SELECT DISTINCT(id)
$result = pwg_query($query);
$subcats = array();
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push($subcats, $row['id']);
}
@@ -533,7 +533,7 @@ WHERE
).'
LIMIT 1';
- $show_link = mysql_num_rows(pwg_query($query)) <> 0;
+ $show_link = pwg_db_num_rows(pwg_query($query)) <> 0;
}
}
if ($show_link)
diff --git a/include/functions_comment.inc.php b/include/functions_comment.inc.php
index aff7b9a35..f22aa3f6e 100644
--- a/include/functions_comment.inc.php
+++ b/include/functions_comment.inc.php
@@ -100,7 +100,7 @@ function insert_user_comment( &$comm, $key, &$infos )
SELECT COUNT(*) AS user_exists
FROM '.USERS_TABLE.'
WHERE '.$conf['user_fields']['username']." = '".addslashes($comm['author'])."'";
- $row = mysql_fetch_assoc( pwg_query( $query ) );
+ $row = pwg_db_fetch_assoc( pwg_query( $query ) );
if ( $row['user_exists'] == 1 )
{
array_push($infos, l10n('comment_user_exists') );
@@ -138,7 +138,7 @@ SELECT COUNT(*) AS user_exists
SELECT id FROM '.COMMENTS_TABLE.'
WHERE date > FROM_UNIXTIME('.$reference_date.')
AND author_id = '.$comm['author_id'];
- if ( mysql_num_rows( pwg_query( $query ) ) > 0 )
+ if ( pwg_db_num_rows( pwg_query( $query ) ) > 0 )
{
array_push( $infos, l10n('comment_anti-flood') );
$comment_action='reject';
@@ -168,7 +168,7 @@ INSERT INTO '.COMMENTS_TABLE.'
pwg_query($query);
- $comm['id'] = mysql_insert_id();
+ $comm['id'] = pwg_db_insert_id();
if (($comment_action=='validate' and $conf['email_admin_on_comment']) or
($comment_action!='validate' and $conf['email_admin_on_comment_validation']))
@@ -266,7 +266,7 @@ function update_user_comment($comment, $post_key)
SELECT id FROM '.COMMENTS_TABLE.'
WHERE date > FROM_UNIXTIME('.$reference_date.')
AND author_id = '.$comm['author_id'];
- if ( mysql_num_rows( pwg_query( $query ) ) > 0 )
+ if ( pwg_db_num_rows( pwg_query( $query ) ) > 0 )
{
//?? array_push( $infos, l10n('comment_anti-flood') );
$comment_action='reject';
diff --git a/include/functions_mail.inc.php b/include/functions_mail.inc.php
index 50d342535..8ea8ec8ae 100644
--- a/include/functions_mail.inc.php
+++ b/include/functions_mail.inc.php
@@ -351,7 +351,7 @@ order by
$datas = pwg_query($query);
if (!empty($datas))
{
- while ($admin = mysql_fetch_assoc($datas))
+ while ($admin = pwg_db_fetch_assoc($datas))
{
if (!empty($admin['mail_address']))
{
@@ -447,10 +447,10 @@ WHERE
$result = pwg_query($query);
- if (mysql_num_rows($result) > 0)
+ if (pwg_db_num_rows($result) > 0)
{
$list = array();
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$row['template_theme'] = $row['template'];
list($row['template'], $row['theme']) = explode('/', $row['template_theme']);
@@ -476,10 +476,10 @@ WHERE
$result = pwg_query($query);
- if (mysql_num_rows($result) > 0)
+ if (pwg_db_num_rows($result) > 0)
{
$Bcc = array();
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
if (!empty($row['mail_address']))
{
diff --git a/include/functions_notification.inc.php b/include/functions_notification.inc.php
index 5bc3e56b8..b9789ee02 100644
--- a/include/functions_notification.inc.php
+++ b/include/functions_notification.inc.php
@@ -145,7 +145,7 @@ function custom_notification_query($action, $type, $start, $end)
}
$query = 'SELECT count(distinct '.$field_id.') as CountId
'.$query;
- list($count) = mysql_fetch_row(pwg_query($query));
+ list($count) = pwg_db_fetch_row(pwg_query($query));
return $count;
break;
@@ -178,7 +178,7 @@ function custom_notification_query($action, $type, $start, $end)
$infos = array();
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push($infos, $row);
}
@@ -448,7 +448,7 @@ SELECT date_available,
;';
$result = pwg_query($query);
$dates = array();
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push($dates, $row);
}
@@ -468,7 +468,7 @@ SELECT DISTINCT id, path, name, tn_ext, file
;';
$dates[$i]['elements'] = array();
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push($dates[$i]['elements'], $row);
}
@@ -488,7 +488,7 @@ SELECT DISTINCT c.uppercats, COUNT(DISTINCT i.id) img_count
;';
$dates[$i]['categories'] = array();
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push($dates[$i]['categories'], $row);
}
diff --git a/include/functions_plugins.inc.php b/include/functions_plugins.inc.php
index 9f1ecac01..a6bbbb31f 100644
--- a/include/functions_plugins.inc.php
+++ b/include/functions_plugins.inc.php
@@ -238,7 +238,7 @@ SELECT * FROM '.PLUGINS_TABLE;
$result = pwg_query($query);
$plugins = array();
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push($plugins, $row);
}
diff --git a/include/functions_rate.inc.php b/include/functions_rate.inc.php
index 520c257c2..a9b6f804e 100644
--- a/include/functions_rate.inc.php
+++ b/include/functions_rate.inc.php
@@ -124,7 +124,7 @@ SELECT COUNT(rate) AS count
FROM '.RATE_TABLE.'
WHERE element_id = '.$image_id.'
;';
- $row = mysql_fetch_assoc(pwg_query($query));
+ $row = pwg_db_fetch_assoc(pwg_query($query));
$query = '
UPDATE '.IMAGES_TABLE.'
SET average_rate = '.$row['average'].'
diff --git a/include/functions_search.inc.php b/include/functions_search.inc.php
index d9e424471..bb9de6a64 100644
--- a/include/functions_search.inc.php
+++ b/include/functions_search.inc.php
@@ -41,7 +41,7 @@ SELECT rules
FROM '.SEARCH_TABLE.'
WHERE id = '.$search_id.'
;';
- list($serialized_rules) = mysql_fetch_row(pwg_query($query));
+ list($serialized_rules) = pwg_db_fetch_row(pwg_query($query));
return unserialize($serialized_rules);
}
@@ -458,7 +458,7 @@ SELECT i.id,
$by_weights=array();
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{ // weight is important when sorting images by relevance
if ($row['weight'])
{
@@ -489,7 +489,7 @@ SELECT image_id, COUNT(tag_id) AS weight
WHERE tag_id IN ('.implode(',',array_keys($tags)).')
GROUP BY image_id';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{ // weight is important when sorting images by relevance
$image_id=(int)$row['image_id'];
@$by_weights[$image_id] += $row['weight'];
@@ -510,7 +510,7 @@ SELECT id, name, permalink, nb_images
array( 'visible_categories' => 'cat_id' ), "\n AND"
);
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{ // weight is important when sorting images by relevance
if ($row['nb_images']==0)
{
diff --git a/include/functions_session.inc.php b/include/functions_session.inc.php
index 1145d3dcc..79fe21c4d 100644
--- a/include/functions_session.inc.php
+++ b/include/functions_session.inc.php
@@ -121,7 +121,7 @@ SELECT data
$result = pwg_query($query);
if ($result)
{
- $row = mysql_fetch_assoc($result);
+ $row = pwg_db_fetch_assoc($result);
return $row['data'];
}
else
diff --git a/include/functions_tag.inc.php b/include/functions_tag.inc.php
index 033967ca4..c3978ad39 100644
--- a/include/functions_tag.inc.php
+++ b/include/functions_tag.inc.php
@@ -63,7 +63,7 @@ SELECT *
FROM '.TAGS_TABLE;
$result = pwg_query($query);
$tags = array();
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$counter = @$tag_counters[ $row['id'] ];
if ( $counter )
@@ -88,7 +88,7 @@ SELECT *
;';
$result = pwg_query($query);
$tags = array();
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push($tags, $row);
}
@@ -249,7 +249,7 @@ SELECT t.*, count(*) counter
$result = pwg_query($query);
$tags = array();
- while($row = mysql_fetch_assoc($result))
+ while($row = pwg_db_fetch_assoc($result))
{
array_push($tags, $row);
}
@@ -311,7 +311,7 @@ SELECT *
$result = pwg_query($query);
$tags = array();
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push($tags, $row);
}
diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php
index f8f02719f..51f8420c9 100644
--- a/include/functions_user.inc.php
+++ b/include/functions_user.inc.php
@@ -58,7 +58,7 @@ from '.USERS_TABLE.'
where upper('.$conf['user_fields']['email'].') = upper(\''.$mail_address.'\')
'.(is_numeric($user_id) ? 'and '.$conf['user_fields']['id'].' != \''.$user_id.'\'' : '').'
;';
- list($count) = mysql_fetch_row(pwg_query($query));
+ list($count) = pwg_db_fetch_row(pwg_query($query));
if ($count != 0)
{
return l10n('reg_err_mail_address_dbl');
@@ -110,12 +110,12 @@ function register_user($login, $password, $mail_address,
SELECT MAX('.$conf['user_fields']['id'].') + 1
FROM '.USERS_TABLE.'
;';
- list($next_id) = mysql_fetch_row(pwg_query($query));
+ list($next_id) = pwg_db_fetch_row(pwg_query($query));
$insert =
array(
$conf['user_fields']['id'] => $next_id,
- $conf['user_fields']['username'] => mysql_real_escape_string($login),
+ $conf['user_fields']['username'] => pwg_db_real_escape_string($login),
$conf['user_fields']['password'] => $conf['pass_convert']($password),
$conf['user_fields']['email'] => $mail_address
);
@@ -134,7 +134,7 @@ SELECT id
$result = pwg_query($query);
$inserts = array();
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push
(
@@ -249,7 +249,7 @@ SELECT ';
FROM '.USERS_TABLE.'
WHERE '.$conf['user_fields']['id'].' = \''.$user_id.'\'';
- $row = mysql_fetch_assoc(pwg_query($query));
+ $row = pwg_db_fetch_assoc(pwg_query($query));
while (true)
{
@@ -259,7 +259,7 @@ SELECT ui.*, uc.*
ON ui.user_id = uc.user_id
WHERE ui.user_id = \''.$user_id.'\'';
$result = pwg_query($query);
- if (mysql_num_rows($result) > 0)
+ if (pwg_db_num_rows($result) > 0)
{
break;
}
@@ -269,7 +269,7 @@ SELECT ui.*, uc.*
}
}
- $row = array_merge($row, mysql_fetch_assoc($result));
+ $row = array_merge($row, pwg_db_fetch_assoc($result));
foreach ($row as $key => $value)
{
@@ -324,7 +324,7 @@ SELECT COUNT(DISTINCT(image_id)) as total
FROM '.IMAGE_CATEGORY_TABLE.'
WHERE category_id NOT IN ('.$userdata['forbidden_categories'].')
AND image_id '.$userdata['image_access_type'].' ('.$userdata['image_access_list'].')';
- list($userdata['nb_total_images']) = mysql_fetch_row(pwg_query($query));
+ list($userdata['nb_total_images']) = pwg_db_fetch_row(pwg_query($query));
// now we update user cache categories
@@ -428,7 +428,7 @@ SELECT DISTINCT f.image_id
;';
$result = pwg_query($query);
$authorizeds = array();
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push($authorizeds, $row['image_id']);
}
@@ -440,7 +440,7 @@ SELECT image_id
;';
$result = pwg_query($query);
$favorites = array();
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push($favorites, $row['image_id']);
}
@@ -481,7 +481,7 @@ SELECT id
WHERE status = \'private\'
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push($private_array, $row['id']);
}
@@ -523,7 +523,7 @@ SELECT id
WHERE visible = \'false\'
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
array_push($forbidden_array, $row['id']);
}
@@ -647,7 +647,7 @@ FROM '.CATEGORIES_TABLE.' as c
$result = pwg_query($query);
$cats = array();
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$row['user_id'] = $userdata['id'];
$row['count_categories'] = 0;
@@ -692,7 +692,7 @@ function get_userid($username)
{
global $conf;
- $username = mysql_real_escape_string($username);
+ $username = pwg_db_real_escape_string($username);
$query = '
SELECT '.$conf['user_fields']['id'].'
@@ -701,13 +701,13 @@ SELECT '.$conf['user_fields']['id'].'
;';
$result = pwg_query($query);
- if (mysql_num_rows($result) == 0)
+ if (pwg_db_num_rows($result) == 0)
{
return false;
}
else
{
- list($user_id) = mysql_fetch_row($result);
+ list($user_id) = pwg_db_fetch_row($result);
return $user_id;
}
}
@@ -727,7 +727,7 @@ SELECT COUNT(*)
FROM '.USER_FEED_TABLE.'
WHERE id = \''.$key.'\'
;';
- list($count) = mysql_fetch_row(pwg_query($query));
+ list($count) = pwg_db_fetch_row(pwg_query($query));
if (0 == $count)
{
return $key;
@@ -750,7 +750,7 @@ function get_default_user_info($convert_str = true)
' WHERE user_id = '.$conf['default_user_id'].';';
$result = pwg_query($query);
- $cache['default_user'] = mysql_fetch_assoc($result);
+ $cache['default_user'] = pwg_db_fetch_assoc($result);
if ($cache['default_user'] !== false)
{
@@ -865,7 +865,7 @@ function create_user_infos($arg_id, $override_values = null)
if (!empty($user_ids))
{
$inserts = array();
- list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
+ list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
$default_user = get_default_user_info(false);
if ($default_user === false)
@@ -930,9 +930,9 @@ SELECT '.$conf['user_fields']['username'].' AS username
FROM '.USERS_TABLE.'
WHERE '.$conf['user_fields']['id'].' = '.$user_id;
$result = pwg_query($query);
- if (mysql_num_rows($result) > 0)
+ if (pwg_db_num_rows($result) > 0)
{
- $row = mysql_fetch_assoc($result);
+ $row = pwg_db_fetch_assoc($result);
$username = stripslashes($row['username']);
$data = $time.stripslashes($row['username']).$row['password'];
$key = base64_encode(
@@ -1041,7 +1041,7 @@ SELECT '.$conf['user_fields']['id'].' AS id,
FROM '.USERS_TABLE.'
WHERE '.$conf['user_fields']['username'].' = \''.mysql_real_escape_string($username).'\'
;';
- $row = mysql_fetch_assoc(pwg_query($query));
+ $row = pwg_db_fetch_assoc(pwg_query($query));
if ($row['password'] == $conf['pass_convert']($password))
{
log_user($row['id'], $remember_me);
diff --git a/include/picture_comment.inc.php b/include/picture_comment.inc.php
index 599f2229d..c8891493e 100644
--- a/include/picture_comment.inc.php
+++ b/include/picture_comment.inc.php
@@ -93,7 +93,7 @@ if ($page['show_comments'])
SELECT COUNT(*) AS nb_comments
FROM '.COMMENTS_TABLE.'
WHERE image_id='.$page['image_id']." AND validated = 'true'";
- $row = mysql_fetch_assoc( pwg_query( $query ) );
+ $row = pwg_db_fetch_assoc( pwg_query( $query ) );
// navigation bar creation
if (!isset($page['start']))
@@ -140,7 +140,7 @@ $validated_clause.'
;';
$result = pwg_query( $query );
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
if (!empty($row['author']))
{
diff --git a/include/picture_rate.inc.php b/include/picture_rate.inc.php
index 3543cfa37..9c4758241 100644
--- a/include/picture_rate.inc.php
+++ b/include/picture_rate.inc.php
@@ -37,7 +37,7 @@ SELECT COUNT(rate) AS count
FROM '.RATE_TABLE.'
WHERE element_id = '.$picture['current']['id'].'
;';
- $row = mysql_fetch_assoc(pwg_query($query));
+ $row = pwg_db_fetch_assoc(pwg_query($query));
}
else
{ // avg rate null -> no rate -> no need to query db
@@ -67,9 +67,9 @@ SELECT COUNT(rate) AS count
}
$result = pwg_query($query);
- if (mysql_num_rows($result) > 0)
+ if (pwg_db_num_rows($result) > 0)
{
- $row = mysql_fetch_assoc($result);
+ $row = pwg_db_fetch_assoc($result);
$user_rate = $row['rate'];
}
}
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php
index bfb62b913..49dfdc47e 100644
--- a/include/ws_functions.inc.php
+++ b/include/ws_functions.inc.php
@@ -256,7 +256,7 @@ SELECT id, name, permalink, image_order
AND ', $where_clauses);
$result = pwg_query($query);
$cats = array();
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$row['id'] = (int)$row['id'];
$cats[ $row['id'] ] = $row;
@@ -295,7 +295,7 @@ GROUP BY i.id
LIMIT '.(int)($params['per_page']*$params['page']).','.(int)$params['per_page'];
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$image = array();
foreach ( array('id', 'width', 'height', 'hit') as $k )
@@ -405,7 +405,7 @@ SELECT id, name, permalink, uppercats, global_rank,
$result = pwg_query($query);
$cats = array();
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$row['url'] = make_index_url(
array(
@@ -471,7 +471,7 @@ SELECT
$result = pwg_query($query);
$cats = array();
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$id = $row['id'];
$row['nb_images'] = isset($nb_images_of[$id]) ? $nb_images_of[$id] : 0;
@@ -517,7 +517,7 @@ SELECT DISTINCT image_id
),
' AND'
);
- if ( !mysql_num_rows( pwg_query( $query ) ) )
+ if ( !pwg_db_num_rows( pwg_query( $query ) ) )
{
return new PwgError(WS_ERR_INVALID_PARAM, "Invalid image_id");
}
@@ -577,7 +577,7 @@ SELECT * FROM '.IMAGES_TABLE.'
).'
LIMIT 1';
- $image_row = mysql_fetch_assoc(pwg_query($query));
+ $image_row = pwg_db_fetch_assoc(pwg_query($query));
if ($image_row==null)
{
return new PwgError(404, "image_id not found");
@@ -598,7 +598,7 @@ SELECT id, name, permalink, uppercats, global_rank, commentable
$result = pwg_query($query);
$is_commentable = false;
$related_categories = array();
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
if ($row['commentable']=='true')
{
@@ -655,7 +655,7 @@ SELECT COUNT(rate) AS count
FROM '.RATE_TABLE.'
WHERE element_id = '.$image_row['id'].'
;';
- $rating = mysql_fetch_assoc(pwg_query($query));
+ $rating = pwg_db_fetch_assoc(pwg_query($query));
$rating['count'] = (int)$rating['count'];
//---------------------------------------------------------- related comments
@@ -686,7 +686,7 @@ SELECT id, date, author, content
','.(int)$params['comments_per_page'];
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$row['id']=(int)$row['id'];
array_push($related_comments, $row);
@@ -757,7 +757,7 @@ SELECT DISTINCT id FROM '.IMAGES_TABLE.'
' AND'
).'
LIMIT 1';
- if ( mysql_num_rows( pwg_query($query) )==0 )
+ if ( pwg_db_num_rows( pwg_query($query) )==0 )
{
return new PwgError(404, "Invalid image_id or access denied" );
}
@@ -813,7 +813,7 @@ SELECT * FROM '.IMAGES_TABLE.'
$image_ids = array_flip($image_ids);
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$image = array();
foreach ( array('id', 'width', 'height', 'hit') as $k )
@@ -870,7 +870,7 @@ UPDATE '.IMAGES_TABLE.'
SET level='.(int)$params['level'].'
WHERE id IN ('.implode(',',$params['image_id']).')';
$result = pwg_query($query);
- $affected_rows = mysql_affected_rows();
+ $affected_rows = pwg_db_affected_rows();
if ($affected_rows)
{
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
@@ -1007,13 +1007,13 @@ SELECT
FROM '.IMAGES_TABLE.'
WHERE md5sum = \''.$params['original_sum'].'\'
;';
- list($counter) = mysql_fetch_row(pwg_query($query));
+ list($counter) = pwg_db_fetch_row(pwg_query($query));
if ($counter != 0) {
return new PwgError(500, 'file already exists');
}
// current date
- list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
+ list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
list($year, $month, $day) = preg_split('/[^\d]/', $dbnow, 4);
// upload directory hierarchy
@@ -1199,7 +1199,7 @@ SELECT
array($insert)
);
- $image_id = mysql_insert_id();
+ $image_id = pwg_db_insert_id();
// let's add links between the image and the categories
if (isset($params['categories']))
@@ -1358,7 +1358,7 @@ SELECT image_id, GROUP_CONCAT(tag_id) tag_ids
WHERE tag_id IN ('.implode(',',$tag_ids).')
GROUP BY image_id';
$result = pwg_query($query);
- while ( $row=mysql_fetch_assoc($result) )
+ while ( $row=pwg_db_fetch_assoc($result) )
{
$row['image_id'] = (int)$row['image_id'];
array_push( $image_ids, $row['image_id'] );
@@ -1401,7 +1401,7 @@ SELECT DISTINCT i.* FROM '.IMAGES_TABLE.' i
LIMIT '.(int)($params['per_page']*$params['page']).','.(int)$params['per_page'];
$result = pwg_query($query);
- while ($row = mysql_fetch_assoc($result))
+ while ($row = pwg_db_fetch_assoc($result))
{
$image = array();
foreach ( array('id', 'width', 'height', 'hit') as $k )
@@ -1572,7 +1572,7 @@ SELECT *
WHERE id = '.$params['image_id'].'
;';
- $image_row = mysql_fetch_assoc(pwg_query($query));
+ $image_row = pwg_db_fetch_assoc(pwg_query($query));
if ($image_row == null)
{
return new PwgError(404, "image_id not found");