mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-08-08 09:43:01 +02:00
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
This commit is contained in:
@@ -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']);
|
||||
|
||||
@@ -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'],
|
||||
|
||||
@@ -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)'));
|
||||
}
|
||||
|
||||
|
||||
@@ -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']);
|
||||
}
|
||||
|
||||
@@ -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']))
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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'])
|
||||
{
|
||||
|
||||
@@ -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']);
|
||||
}
|
||||
|
||||
@@ -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']))
|
||||
{
|
||||
|
||||
@@ -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'];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user