Skip to content
Permalink
Browse files

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
  • Loading branch information...
nikrou
nikrou committed Nov 15, 2009
1 parent dda7f45 commit 1040cae2104259fdec8543e0a41ac63cbe24c69c
Showing with 136 additions and 136 deletions.
  1. +2 −2 admin/cat_modify.php
  2. +5 −5 admin/cat_perm.php
  3. +1 −1 admin/configuration.php
  4. +1 −1 admin/element_set.php
  5. +1 −1 admin/element_set_global.php
  6. +1 −1 admin/element_set_ranks.php
  7. +1 −1 admin/element_set_unit.php
  8. +1 −1 admin/group_list.php
  9. +3 −3 admin/group_perm.php
  10. +3 −3 admin/history.php
  11. +1 −1 admin/include/c13y_internal.class.php
  12. +22 −22 admin/include/functions.php
  13. +2 −2 admin/include/functions_metadata.php
  14. +1 −1 admin/include/functions_notification_by_mail.inc.php
  15. +2 −2 admin/include/functions_permalinks.php
  16. +2 −2 admin/notification_by_mail.php
  17. +3 −3 admin/picture_modify.php
  18. +2 −2 admin/rating.php
  19. +3 −3 admin/site_manager.php
  20. +7 −7 admin/site_update.php
  21. +2 −2 admin/stats.php
  22. +2 −2 admin/tags.php
  23. +2 −2 admin/upload.php
  24. +3 −3 admin/user_list.php
  25. +4 −4 admin/user_perm.php
  26. +3 −3 include/calendar_monthly.class.php
  27. +1 −1 include/category_cats.inc.php
  28. +6 −6 include/functions.inc.php
  29. +4 −4 include/functions_category.inc.php
  30. +3 −3 include/functions_mail.inc.php
  31. +2 −2 include/functions_notification.inc.php
  32. +1 −1 include/functions_plugins.inc.php
  33. +1 −1 include/functions_search.inc.php
  34. +10 −10 include/functions_user.inc.php
  35. +2 −2 include/picture_comment.inc.php
  36. +2 −2 include/picture_rate.inc.php
  37. +1 −1 install/db/12-database.php
  38. +1 −1 install/db/18-database.php
  39. +1 −1 install/db/19-database.php
  40. +1 −1 install/db/20-database.php
  41. +2 −2 install/db/65-database.php
  42. +1 −1 install/db/8-database.php
  43. +1 −1 install/db/9-database.php
  44. +1 −1 install/upgrade_1.3.0.php
  45. +4 −4 install/upgrade_1.3.1.php
  46. +2 −2 install/upgrade_1.4.0.php
  47. +3 −3 install/upgrade_1.5.0.php
  48. +1 −1 password.php
  49. +3 −3 picture.php
  50. +1 −1 search_rules.php
  51. +1 −1 upload.php
@@ -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)
{
@@ -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'];
@@ -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)
{
@@ -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));
}
// +-----------------------------------------------------------------------+
@@ -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']);
}
@@ -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']);
}
@@ -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']]))
{
@@ -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']]))
{
@@ -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.'
@@ -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'];
@@ -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(
@@ -56,7 +56,7 @@
;';
$result = pwg_query($query);
while ($row = mysql_fetch_array($result))
while ($row = mysql_fetch_assoc($result))
{
$data = array();
@@ -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(*)
@@ -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']);
}
@@ -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']);
}
@@ -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']);
}
@@ -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'];
}
@@ -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'];
@@ -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'];
}
@@ -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'];
}
@@ -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']);
}
@@ -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']);
}
@@ -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))
{
@@ -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)
{
@@ -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']));
@@ -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,
@@ -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);
}
@@ -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,
@@ -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(
@@ -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,
@@ -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
@@ -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]);
}
@@ -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')
{
@@ -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']);
}
@@ -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'];
}
@@ -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);
}
@@ -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;
}
@@ -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
Oops, something went wrong.

0 comments on commit 1040cae

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.