diff options
author | plegall <plg@piwigo.org> | 2004-12-05 22:02:36 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2004-12-05 22:02:36 +0000 |
commit | 484a431a7e257ab6f8484a9e4100d70657da17ea (patch) | |
tree | 514ea5f28000f85e2f207e9ad6a4154279227bb6 /admin | |
parent | 964f9774015525f3cfe4e10509744f6c4494e782 (diff) |
if all links between a category and elements have disappeared, no line is
returned by the update_category query but the update must be done with
nb_images = 0 and date_last = NULL
git-svn-id: http://piwigo.org/svn/trunk@637 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r-- | admin/include/functions.php | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/admin/include/functions.php b/admin/include/functions.php index 0d2972740..987cddb9a 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -504,15 +504,24 @@ SELECT category_id, FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id WHERE category_id IN ('.implode(',', $cat_ids).') GROUP BY category_id -'; +;'; $result = pwg_query($query); $datas = array(); + $query_ids = array(); while ( $row = mysql_fetch_array( $result ) ) { + array_push($query_ids, $row['category_id']); array_push($datas, array('id' => $row['category_id'], 'date_last' => $row['date_last'], 'nb_images' => $row['nb_images'])); } + // if all links between a category and elements have disappeared, no line + // is returned but the update must be done ! + foreach (array_diff($cat_ids, $query_ids) as $id) + { + array_push($datas, array('id' => $id, 'nb_images' => 0)); + } + $fields = array('primary' => array('id'), 'update' => array('date_last', 'nb_images')); mass_updates(CATEGORIES_TABLE, $fields, $datas); |