Skip to content

Commit

Permalink
Feature 1241 resolved. replace mysql_fetch_array by mysql_fetch_assoc…
Browse files Browse the repository at this point in the history
… for small php code improvements

git-svn-id: http://piwigo.org/svn/trunk@4265 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
nikrou committed Nov 15, 2009
1 parent dda7f45 commit 1040cae
Show file tree
Hide file tree
Showing 51 changed files with 136 additions and 136 deletions.
4 changes: 2 additions & 2 deletions admin/cat_modify.php
Expand Up @@ -193,7 +193,7 @@
FROM '.CATEGORIES_TABLE.'
WHERE id = '.$_GET['cat_id'].'
;';
$category = mysql_fetch_array( pwg_query( $query ) );
$category = mysql_fetch_assoc( pwg_query( $query ) );
// nullable fields
foreach (array('comment','dir','site_id', 'id_uppercat') as $nullable)
{
Expand Down Expand Up @@ -373,7 +373,7 @@
FROM '.IMAGES_TABLE.'
WHERE id = '.$category['representative_picture_id'].'
;';
$row = mysql_fetch_array(pwg_query($query));
$row = mysql_fetch_assoc(pwg_query($query));
$src = get_thumbnail_url($row);
$url = get_root_url().'admin.php?page=picture_modify';
$url.= '&image_id='.$category['representative_picture_id'];
Expand Down
10 changes: 5 additions & 5 deletions admin/cat_perm.php
Expand Up @@ -45,7 +45,7 @@
FROM '.CATEGORIES_TABLE.'
WHERE id = '.$_GET['cat'].'
;';
list($status) = mysql_fetch_array(pwg_query($query));
list($status) = mysql_fetch_row(pwg_query($query));

if ('private' == $status)
{
Expand All @@ -62,7 +62,7 @@
LIMIT 0,1
;';

list($page['cat']) = mysql_fetch_array(pwg_query($query));
list($page['cat']) = mysql_fetch_row(pwg_query($query));
}

// +-----------------------------------------------------------------------+
Expand Down Expand Up @@ -110,7 +110,7 @@
AND group_id IN ('.implode(',', $_POST['grant_groups']).')
;';
$result = pwg_query($query);
while ($row = mysql_fetch_array($result))
while ($row = mysql_fetch_assoc($result))
{
array_push($granteds[$row['cat_id']], $row['group_id']);
}
Expand Down Expand Up @@ -169,7 +169,7 @@
AND user_id IN ('.implode(',', $_POST['grant_users']).')
;';
$result = pwg_query($query);
while ($row = mysql_fetch_array($result))
while ($row = mysql_fetch_assoc($result))
{
array_push($granteds[$row['cat_id']], $row['user_id']);
}
Expand Down Expand Up @@ -274,7 +274,7 @@
WHERE group_id IN ('.implode(',', $group_granted_ids).')
';
$result = pwg_query($query);
while ($row = mysql_fetch_array($result))
while ($row = mysql_fetch_assoc($result))
{
if (!isset($granted_groups[$row['group_id']]))
{
Expand Down
2 changes: 1 addition & 1 deletion admin/configuration.php
Expand Up @@ -138,7 +138,7 @@
{
//echo '<pre>'; print_r($_POST); echo '</pre>';
$result = pwg_query('SELECT param FROM '.CONFIG_TABLE);
while ($row = mysql_fetch_array($result))
while ($row = mysql_fetch_assoc($result))
{
if (isset($_POST[$row['param']]))
{
Expand Down
2 changes: 1 addition & 1 deletion admin/element_set.php
Expand Up @@ -192,7 +192,7 @@
$page['title'] = l10n('recent_pics_cat');
$query = 'SELECT MAX(date_available) AS date
FROM '.IMAGES_TABLE;
if ($row=mysql_fetch_array( pwg_query($query) ) )
if ($row = mysql_fetch_assoc( pwg_query($query) ) )
{
$query = 'SELECT id
FROM '.IMAGES_TABLE.'
Expand Down
2 changes: 1 addition & 1 deletion admin/element_set_global.php
Expand Up @@ -245,7 +245,7 @@
;';
$result = pwg_query($query);

while ($row = mysql_fetch_array($result))
while ($row = mysql_fetch_assoc($result))
{
$data = array();
$data['id'] = $row['id'];
Expand Down
2 changes: 1 addition & 1 deletion admin/element_set_ranks.php
Expand Up @@ -115,7 +115,7 @@ function save_images_order($category_id, $images)
FROM '.CATEGORIES_TABLE.'
WHERE id = '.$page['category_id'].'
;';
$category = mysql_fetch_array(pwg_query($query));
$category = mysql_fetch_assoc(pwg_query($query));

// Navigation path
$navigation = get_cat_display_name_cache(
Expand Down
2 changes: 1 addition & 1 deletion admin/element_set_unit.php
Expand Up @@ -56,7 +56,7 @@
;';
$result = pwg_query($query);

while ($row = mysql_fetch_array($result))
while ($row = mysql_fetch_assoc($result))
{
$data = array();

Expand Down
2 changes: 1 addition & 1 deletion admin/group_list.php
Expand Up @@ -175,7 +175,7 @@
$members_url = $admin_url.'user_list&amp;group=';
$toggle_is_default_url = $admin_url.'group_list&amp;toggle_is_default=';

while ($row = mysql_fetch_array($result))
while ($row = mysql_fetch_assoc($result))
{
$query = '
SELECT COUNT(*)
Expand Down
6 changes: 3 additions & 3 deletions admin/group_perm.php
Expand Up @@ -79,7 +79,7 @@
AND status = \'private\'
;';
$result = pwg_query($query);
while ($row = mysql_fetch_array($result))
while ($row = mysql_fetch_assoc($result))
{
array_push($private_uppercats, $row['id']);
}
Expand All @@ -96,7 +96,7 @@
;';
$result = pwg_query($query);

while ($row = mysql_fetch_array($result))
while ($row = mysql_fetch_assoc($result))
{
array_push($authorized_ids, $row['cat_id']);
}
Expand Down Expand Up @@ -157,7 +157,7 @@

$result = pwg_query($query_true);
$authorized_ids = array();
while ($row = mysql_fetch_array($result))
while ($row = mysql_fetch_assoc($result))
{
array_push($authorized_ids, $row['id']);
}
Expand Down
6 changes: 3 additions & 3 deletions admin/history.php
Expand Up @@ -257,7 +257,7 @@
$result = pwg_query($query);

$username_of = array();
while ($row = mysql_fetch_array($result))
while ($row = mysql_fetch_assoc($result))
{
$username_of[$row['id']] = $row['username'];
}
Expand Down Expand Up @@ -305,7 +305,7 @@
$tn_ext_of_image = array();

$result = pwg_query($query);
while ($row = mysql_fetch_array($result))
while ($row = mysql_fetch_assoc($result))
{
$label_of_image[ $row['id'] ] = $row['label'];

Expand Down Expand Up @@ -341,7 +341,7 @@
$name_of_tag = array();

$result = pwg_query($query);
while ($row = mysql_fetch_array($result))
while ($row = mysql_fetch_assoc($result))
{
$name_of_tag[ $row['id'] ] = $row['name'];
}
Expand Down
2 changes: 1 addition & 1 deletion admin/include/c13y_internal.class.php
Expand Up @@ -126,7 +126,7 @@ function c13y_user($c13y)
$status = array();

$result = pwg_query($query);
while ($row = mysql_fetch_array($result))
while ($row = mysql_fetch_assoc($result))
{
$status[$row['id']] = $row['status'];
}
Expand Down
44 changes: 22 additions & 22 deletions admin/include/functions.php
Expand Up @@ -36,7 +36,7 @@ function delete_site( $id )
;';
$result = pwg_query($query);
$category_ids = array();
while ($row = mysql_fetch_array($result))
while ($row = mysql_fetch_assoc($result))
{
array_push($category_ids, $row['id']);
}
Expand Down Expand Up @@ -77,7 +77,7 @@ function delete_categories($ids)
;';
$result = pwg_query($query);
$element_ids = array();
while ($row = mysql_fetch_array($result))
while ($row = mysql_fetch_assoc($result))
{
array_push($element_ids, $row['id']);
}
Expand Down Expand Up @@ -544,7 +544,7 @@ function mass_updates($tablename, $dbfields, $datas, $flags=0)
$result = pwg_query($query);
$columns = array();
$all_fields = array_merge($dbfields['primary'], $dbfields['update']);
while ($row = mysql_fetch_array($result))
while ($row = mysql_fetch_assoc($result))
{
if (in_array($row['Field'], $all_fields))
{
Expand Down Expand Up @@ -630,7 +630,7 @@ function update_global_rank()
$current_uppercat = '';

$result = pwg_query($query);
while ($row = mysql_fetch_array($result))
while ($row = mysql_fetch_assoc($result))
{
if ($row['id_uppercat'] != $current_uppercat)
{
Expand Down Expand Up @@ -776,7 +776,7 @@ function get_uppercat_ids($cat_ids)
WHERE id IN ('.implode(',', $cat_ids).')
;';
$result = pwg_query($query);
while ($row = mysql_fetch_array($result))
while ($row = mysql_fetch_assoc($result))
{
$uppercats = array_merge($uppercats,
explode(',', $row['uppercats']));
Expand All @@ -803,7 +803,7 @@ function set_random_representant($categories)
ORDER BY RAND()
LIMIT 0,1
;';
list($representative) = mysql_fetch_array(pwg_query($query));
list($representative) = mysql_fetch_row(pwg_query($query));

array_push(
$datas,
Expand Down Expand Up @@ -863,7 +863,7 @@ function get_fulldirs($cat_ids)
'.wordwrap(implode(', ', $cat_ids), 80, "\n").')
;';
$result = pwg_query($query);
while ($row = mysql_fetch_array($result))
while ($row = mysql_fetch_assoc($result))
{
array_push($categories, $row);
}
Expand Down Expand Up @@ -1139,7 +1139,7 @@ function update_average_rate( $element_id=-1 )

$datas = array();

while ($row = mysql_fetch_array($result))
while ($row = mysql_fetch_assoc($result))
{
array_push(
$datas,
Expand Down Expand Up @@ -1206,7 +1206,7 @@ function move_categories($category_ids, $new_parent = -1)
WHERE id IN ('.implode(',', $category_ids).')
;';
$result = pwg_query($query);
while ($row = mysql_fetch_array($result))
while ($row = mysql_fetch_assoc($result))
{
$categories[$row['id']] =
array(
Expand Down Expand Up @@ -1355,7 +1355,7 @@ function create_virtual_category($category_name, $parent_id=null)
FROM '.CATEGORIES_TABLE.'
WHERE id_uppercat '.(is_numeric($parent_id) ? '= '.$parent_id : 'IS NULL').'
;';
list($current_rank) = mysql_fetch_array(pwg_query($query));
list($current_rank) = mysql_fetch_row(pwg_query($query));

$insert = array(
'name' => $category_name,
Expand All @@ -1371,40 +1371,40 @@ function create_virtual_category($category_name, $parent_id=null)
FROM '.CATEGORIES_TABLE.'
WHERE id = '.$parent_id.'
;';
$parent = mysql_fetch_array(pwg_query($query));
$parent = mysql_fetch_assoc(pwg_query($query));

$insert{'id_uppercat'} = $parent{'id'};
$insert{'global_rank'} = $parent{'global_rank'}.'.'.$insert{'rank'};
$insert['id_uppercat'] = $parent['id'];
$insert['global_rank'] = $parent['global_rank'].'.'.$insert['rank'];

// at creation, must a category be visible or not ? Warning : if the
// parent category is invisible, the category is automatically create
// invisible. (invisible = locked)
if ('false' == $parent['visible'])
{
$insert{'visible'} = 'false';
$insert['visible'] = 'false';
}
else
{
$insert{'visible'} = boolean_to_string($conf['newcat_default_visible']);
$insert['visible'] = boolean_to_string($conf['newcat_default_visible']);
}

// at creation, must a category be public or private ? Warning : if the
// parent category is private, the category is automatically create
// private.
if ('private' == $parent['status'])
{
$insert{'status'} = 'private';
$insert['status'] = 'private';
}
else
{
$insert{'status'} = $conf['newcat_default_status'];
$insert['status'] = $conf['newcat_default_status'];
}
}
else
{
$insert{'visible'} = boolean_to_string($conf['newcat_default_visible']);
$insert{'status'} = $conf['newcat_default_status'];
$insert{'global_rank'} = $insert{'rank'};
$insert['visible'] = boolean_to_string($conf['newcat_default_visible']);
$insert['status'] = $conf['newcat_default_status'];
$insert['global_rank'] = $insert['rank'];
}

// we have then to add the virtual category
Expand Down Expand Up @@ -1609,7 +1609,7 @@ function do_maintenance_all_tables()
// List all tables
$query = 'SHOW TABLES LIKE \''.$prefixeTable.'%\'';
$result = pwg_query($query);
while ($row = mysql_fetch_array($result))
while ($row = mysql_fetch_assoc($result))
{
array_push($all_tables, $row[0]);
}
Expand All @@ -1625,7 +1625,7 @@ function do_maintenance_all_tables()

$query = 'DESC '.$table_name.';';
$result = pwg_query($query);
while ($row = mysql_fetch_array($result))
while ($row = mysql_fetch_assoc($result))
{
if ($row['Key'] == 'PRI')
{
Expand Down
4 changes: 2 additions & 2 deletions admin/include/functions_metadata.php
Expand Up @@ -259,7 +259,7 @@ function get_filelist($category_id = '', $site_id=1, $recursive = false,
$query.= '
;';
$result = pwg_query($query);
while ($row = mysql_fetch_array($result))
while ($row = mysql_fetch_assoc($result))
{
array_push($cat_ids, $row['id']);
}
Expand All @@ -284,7 +284,7 @@ function get_filelist($category_id = '', $site_id=1, $recursive = false,
$query.= '
;';
$result = pwg_query($query);
while ($row = mysql_fetch_array($result))
while ($row = mysql_fetch_assoc($result))
{
$files[$row['id']] = $row['path'];
}
Expand Down
2 changes: 1 addition & 1 deletion admin/include/functions_notification_by_mail.inc.php
Expand Up @@ -167,7 +167,7 @@ function get_user_notifications($action, $check_key_list = array(), $enabled_fil
$result = pwg_query($query);
if (!empty($result))
{
while ($nbm_user = mysql_fetch_array($result))
while ($nbm_user = mysql_fetch_assoc($result))
{
array_push($data_users, $nbm_user);
}
Expand Down
4 changes: 2 additions & 2 deletions admin/include/functions_permalinks.php
Expand Up @@ -52,7 +52,7 @@ function get_cat_id_from_old_permalink($permalink)
$result = pwg_query($query);
$cat_id = null;
if ( mysql_num_rows($result) )
list( $cat_id ) = mysql_fetch_array($result);
list( $cat_id ) = mysql_fetch_row($result);
return $cat_id;
}

Expand All @@ -74,7 +74,7 @@ function delete_cat_permalink( $cat_id, $save )
$result = pwg_query($query);
if ( mysql_num_rows($result) )
{
list($permalink) = mysql_fetch_array($result);
list($permalink) = mysql_fetch_row($result);
}
if ( !isset($permalink) )
{// no permalink; nothing to do
Expand Down

0 comments on commit 1040cae

Please sign in to comment.