aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authornikrou <nikrou@piwigo.org>2009-11-15 12:26:09 +0000
committernikrou <nikrou@piwigo.org>2009-11-15 12:26:09 +0000
commit1040cae2104259fdec8543e0a41ac63cbe24c69c (patch)
treef1a08573c7d2bdf1b8634263226fd42de7088848 /include
parentdda7f4571b72323c4e53ce5ef4a42412b65da3bd (diff)
Feature 1241 resolved. replace mysql_fetch_array by mysql_fetch_assoc for small php code improvements
git-svn-id: http://piwigo.org/svn/trunk@4265 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/calendar_monthly.class.php6
-rw-r--r--include/category_cats.inc.php2
-rw-r--r--include/functions.inc.php12
-rw-r--r--include/functions_category.inc.php8
-rw-r--r--include/functions_mail.inc.php6
-rw-r--r--include/functions_notification.inc.php4
-rw-r--r--include/functions_plugins.inc.php2
-rw-r--r--include/functions_search.inc.php2
-rw-r--r--include/functions_user.inc.php20
-rw-r--r--include/picture_comment.inc.php4
-rw-r--r--include/picture_rate.inc.php4
11 files changed, 35 insertions, 35 deletions
diff --git a/include/calendar_monthly.class.php b/include/calendar_monthly.class.php
index 4a25e0ee4..b4df9f5f8 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_array($result))
+ while ($row = mysql_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_array($result))
+ while ($row = mysql_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_array($result))
+ while ($row = mysql_fetch_assoc($result))
{
$d = (int)$row['period'];
$items[$d] = array('nb_images'=>$row['count']);
diff --git a/include/category_cats.inc.php b/include/category_cats.inc.php
index 43f4776fc..1cd7c0407 100644
--- a/include/category_cats.inc.php
+++ b/include/category_cats.inc.php
@@ -178,7 +178,7 @@ SELECT
GROUP BY category_id
;';
$result = pwg_query($query);
- while ($row = mysql_fetch_array($result))
+ while ($row = mysql_fetch_assoc($result))
{
$dates_of_category[ $row['category_id'] ] = array(
'from' => $row['date_creation_min'],
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 84bf02460..7353eda6a 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_array($result))
+ while ($row = mysql_fetch_assoc($result))
{
// we are only interested in the the field given in parameter for the
// function
@@ -935,7 +935,7 @@ function array_from_query($query, $fieldname)
$array = array();
$result = pwg_query($query);
- while ($row = mysql_fetch_array($result))
+ while ($row = mysql_fetch_assoc($result))
{
array_push($array, $row[$fieldname]);
}
@@ -1121,7 +1121,7 @@ SELECT '.$conf['user_fields']['email'].'
FROM '.USERS_TABLE.'
WHERE '.$conf['user_fields']['id'].' = '.$conf['webmaster_id'].'
;';
- list($email) = mysql_fetch_array(pwg_query($query));
+ list($email) = mysql_fetch_row(pwg_query($query));
return $email;
}
@@ -1147,7 +1147,7 @@ SELECT param, value
fatal_error('No configuration data');
}
- while ($row = mysql_fetch_array($result))
+ while ($row = mysql_fetch_assoc($result))
{
$conf[ $row['param'] ] = isset($row['value']) ? $row['value'] : '';
@@ -1192,7 +1192,7 @@ function simple_hash_from_query($query, $keyname, $valuename)
$array = array();
$result = pwg_query($query);
- while ($row = mysql_fetch_array($result))
+ while ($row = mysql_fetch_assoc($result))
{
$array[ $row[$keyname] ] = $row[$valuename];
}
@@ -1584,7 +1584,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_array(pwg_query('select SUBDATE(
+ mysql_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 a96347258..dd2707b10 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -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_array( pwg_query( $query ) );
+ $row = mysql_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_array( $result ) )
+ while( $row = mysql_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_array(pwg_query($query));
+ $row = mysql_fetch_assoc(pwg_query($query));
return $row['galleries_url'];
}
@@ -384,7 +384,7 @@ SELECT DISTINCT(id)
$result = pwg_query($query);
$subcats = array();
- while ($row = mysql_fetch_array($result))
+ while ($row = mysql_fetch_assoc($result))
{
array_push($subcats, $row['id']);
}
diff --git a/include/functions_mail.inc.php b/include/functions_mail.inc.php
index f1e0ba4ff..905ad3e70 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_array($datas))
+ while ($admin = mysql_fetch_assoc($datas))
{
if (!empty($admin['mail_address']))
{
@@ -450,7 +450,7 @@ WHERE
if (mysql_num_rows($result) > 0)
{
$list = array();
- while ($row = mysql_fetch_array($result))
+ while ($row = mysql_fetch_assoc($result))
{
$row['template_theme'] = $row['template'];
list($row['template'], $row['theme']) = explode('/', $row['template_theme']);
@@ -479,7 +479,7 @@ WHERE
if (mysql_num_rows($result) > 0)
{
$Bcc = array();
- while ($row = mysql_fetch_array($result))
+ while ($row = mysql_fetch_assoc($result))
{
if (!empty($row['mail_address']))
{
diff --git a/include/functions_notification.inc.php b/include/functions_notification.inc.php
index 7e630439c..5bc3e56b8 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_array(pwg_query($query));
+ list($count) = mysql_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_array($result))
+ while ($row = mysql_fetch_assoc($result))
{
array_push($infos, $row);
}
diff --git a/include/functions_plugins.inc.php b/include/functions_plugins.inc.php
index 5a5ea79e3..9f1ecac01 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_array($result))
+ while ($row = mysql_fetch_assoc($result))
{
array_push($plugins, $row);
}
diff --git a/include/functions_search.inc.php b/include/functions_search.inc.php
index fcd58ceff..d9e424471 100644
--- a/include/functions_search.inc.php
+++ b/include/functions_search.inc.php
@@ -458,7 +458,7 @@ SELECT i.id,
$by_weights=array();
$result = pwg_query($query);
- while ($row = mysql_fetch_array($result))
+ while ($row = mysql_fetch_assoc($result))
{ // weight is important when sorting images by relevance
if ($row['weight'])
{
diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php
index 98a417ecb..c1f7029d4 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_array(pwg_query($query));
+ list($count) = mysql_fetch_row(pwg_query($query));
if ($count != 0)
{
return l10n('reg_err_mail_address_dbl');
@@ -110,7 +110,7 @@ function register_user($login, $password, $mail_address,
SELECT MAX('.$conf['user_fields']['id'].') + 1
FROM '.USERS_TABLE.'
;';
- list($next_id) = mysql_fetch_array(pwg_query($query));
+ list($next_id) = mysql_fetch_row(pwg_query($query));
$insert =
array(
@@ -134,7 +134,7 @@ SELECT id
$result = pwg_query($query);
$inserts = array();
- while ($row = mysql_fetch_array($result))
+ while ($row = mysql_fetch_assoc($result))
{
array_push
(
@@ -249,7 +249,7 @@ SELECT ';
FROM '.USERS_TABLE.'
WHERE '.$conf['user_fields']['id'].' = \''.$user_id.'\'';
- $row = mysql_fetch_array(pwg_query($query));
+ $row = mysql_fetch_assoc(pwg_query($query));
while (true)
{
@@ -269,7 +269,7 @@ SELECT ui.*, uc.*
}
}
- $row = array_merge($row, mysql_fetch_array($result));
+ $row = array_merge($row, mysql_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_array(pwg_query($query));
+ list($userdata['nb_total_images']) = mysql_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_array($result))
+ while ($row = mysql_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_array($result))
+ while ($row = mysql_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_array($result))
+ while ($row = mysql_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_array($result))
+ while ($row = mysql_fetch_assoc($result))
{
array_push($forbidden_array, $row['id']);
}
diff --git a/include/picture_comment.inc.php b/include/picture_comment.inc.php
index 5ebf08fc9..a0aed7a70 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_array( pwg_query( $query ) );
+ $row = mysql_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_array($result))
+ while ($row = mysql_fetch_assoc($result))
{
if (!empty($row['author']))
{
diff --git a/include/picture_rate.inc.php b/include/picture_rate.inc.php
index bfb99453c..3543cfa37 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_array(pwg_query($query));
+ $row = mysql_fetch_assoc(pwg_query($query));
}
else
{ // avg rate null -> no rate -> no need to query db
@@ -69,7 +69,7 @@ SELECT COUNT(rate) AS count
$result = pwg_query($query);
if (mysql_num_rows($result) > 0)
{
- $row = mysql_fetch_array($result);
+ $row = mysql_fetch_assoc($result);
$user_rate = $row['rate'];
}
}