Changeset 625 for trunk/admin/update.php
- Timestamp:
- Nov 30, 2004, 9:26:44 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/update.php
r614 r625 43 43 * (insides its sub-category), even the newer that have none at te 44 44 * beginning. For this, ordering function selects all categories ordered by 45 * rank ASC then name ASC for each uppercat. It also updates the global rank 46 * which is able to order any two categorie in the whole tree 45 * rank ASC then name ASC for each uppercat. 47 46 * 48 47 * @returns void … … 59 58 ;'; 60 59 $result = pwg_query($query); 60 $datas = array(); 61 61 while ($row = mysql_fetch_array($result)) 62 62 { … … 66 66 $current_uppercat = $row['id_uppercat']; 67 67 } 68 $query = ' 69 UPDATE '.CATEGORIES_TABLE.' 70 SET rank = '.++$current_rank.' 71 WHERE id = '.$row['id'].' 72 ;'; 73 pwg_query($query); 74 } 75 // global rank update 76 $query = ' 77 UPDATE '.CATEGORIES_TABLE.' 78 SET global_rank = rank 79 WHERE id_uppercat IS NULL 80 ;'; 81 pwg_query($query); 82 83 $query = ' 84 SELECT DISTINCT(id_uppercat) 85 FROM '.CATEGORIES_TABLE.' 86 WHERE id_uppercat IS NOT NULL 87 ;'; 88 $result = pwg_query($query); 89 while ($row = mysql_fetch_array($result)) 90 { 91 $query = ' 92 SELECT global_rank 93 FROM '.CATEGORIES_TABLE.' 94 WHERE id = '.$row['id_uppercat'].' 95 ;'; 96 list($uppercat_global_rank) = mysql_fetch_array(pwg_query($query)); 97 $query = ' 98 UPDATE '.CATEGORIES_TABLE.' 99 SET global_rank = CONCAT(\''.$uppercat_global_rank.'\', \'.\', rank) 100 WHERE id_uppercat = '.$row['id_uppercat'].' 101 ;'; 102 pwg_query($query); 103 } 68 $data = array('id' => $row['id'], 'rank' => ++$current_rank); 69 array_push($datas, $data); 70 } 71 72 $fields = array('primary' => array('id'), 'update' => array('rank')); 73 mass_updates(CATEGORIES_TABLE, $fields, $datas); 104 74 } 105 75 … … 651 621 $start = get_moment(); 652 622 ordering(); 623 update_global_rank(); 653 624 echo get_elapsed_time($start, get_moment()).' for ordering categories<br />'; 654 625 }
Note: See TracChangeset
for help on using the changeset viewer.