Changeset 27369


Ignore:
Timestamp:
02/13/14 23:21:12 (5 years ago)
Author:
rvelices
Message:

more query2array

Location:
trunk/include
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/calendar_base.class.php

    r26865 r27369  
    247247  GROUP BY period;'; 
    248248 
    249     $level_items = simple_hash_from_query($query, 'period', 'nb_images'); 
     249    $level_items = query2array($query, 'period', 'nb_images'); 
    250250 
    251251    if ( count($level_items)==1 and 
     
    318318     
    319319    $current = implode('-', $page['chronology_date'] ); 
    320     $upper_items = array_from_query( $query, 'period'); 
     320    $upper_items = query2array($query,null, 'period'); 
    321321 
    322322    usort($upper_items, 'version_compare'); 
  • trunk/include/category_default.inc.php

    r26461 r27369  
    8585  GROUP BY image_id 
    8686;'; 
    87     $nb_comments_of = simple_hash_from_query($query, 'image_id', 'nb_comments'); 
     87    $nb_comments_of = query2array($query, 'image_id', 'nb_comments'); 
    8888  } 
    8989} 
  • trunk/include/functions.inc.php

    r27336 r27369  
    12541254function simple_hash_from_query($query, $keyname, $valuename) 
    12551255{ 
    1256   $array = array(); 
    1257  
    1258   $result = pwg_query($query); 
    1259   while ($row = pwg_db_fetch_assoc($result)) 
    1260   { 
    1261     $array[ $row[$keyname] ] = $row[$valuename]; 
    1262   } 
    1263  
    1264   return $array; 
     1256        return query2array($query, $keyname, $valuename); 
    12651257} 
    12661258 
     
    12761268function hash_from_query($query, $keyname) 
    12771269{ 
    1278   $array = array(); 
    1279   $result = pwg_query($query); 
    1280   while ($row = pwg_db_fetch_assoc($result)) 
    1281   { 
    1282     $array[ $row[$keyname] ] = $row; 
    1283   } 
    1284   return $array; 
     1270        return query2array($query, $keyname); 
    12851271} 
    12861272 
     
    12971283function array_from_query($query, $fieldname=false) 
    12981284{ 
    1299   $array = array(); 
    1300  
    1301   $result = pwg_query($query); 
    13021285  if (false === $fieldname) 
    13031286  { 
    1304     while ($row = pwg_db_fetch_assoc($result)) 
    1305     { 
    1306       $array[] = $row; 
    1307     } 
     1287                return query2array($query); 
    13081288  } 
    13091289  else 
    13101290  { 
    1311     while ($row = pwg_db_fetch_assoc($result)) 
    1312     { 
    1313       $array[] = $row[$fieldname]; 
    1314     } 
    1315   } 
    1316   return $array; 
     1291                return query2array($query, null, $fieldname); 
     1292  } 
    13171293} 
    13181294 
  • trunk/include/functions_category.inc.php

    r26461 r27369  
    206206    WHERE id IN ('.$cat['uppercats'].') 
    207207  ;'; 
    208     $names = hash_from_query($query, 'id'); 
     208    $names = query2array($query, 'id'); 
    209209 
    210210    // category names must be in the same order than uppercats list 
     
    303303                                    $fullname = true) 
    304304{ 
    305   $categories = array_from_query($query); 
     305  $categories = query2array($query); 
    306306  usort($categories, 'global_rank_compare'); 
    307307  display_select_categories($categories, $selecteds, $blockname, $fullname); 
     
    363363  WHERE permalink IN ('.$in.') 
    364364;'; 
    365   $perma_hash = hash_from_query($query, 'permalink'); 
     365  $perma_hash = query2array($query, 'permalink'); 
    366366 
    367367  if ( empty($perma_hash) ) 
  • trunk/include/functions_html.inc.php

    r26649 r27369  
    114114  FROM '.CATEGORIES_TABLE.' 
    115115;'; 
    116     $cache['cat_names'] = hash_from_query($query, 'id'); 
     116    $cache['cat_names'] = query2array($query, 'id'); 
    117117  } 
    118118 
  • trunk/include/functions_notification.inc.php

    r26461 r27369  
    218218      } 
    219219      $query = 'SELECT DISTINCT '.$field_id.' '.$query.';'; 
    220       $infos = array_from_query($query); 
     220      $infos = query2array($query); 
    221221      return $infos; 
    222222      break; 
     
    457457  LIMIT '.$max_dates.' 
    458458;'; 
    459   $dates = array_from_query($query); 
     459  $dates = query2array($query); 
    460460 
    461461  for ($i=0; $i<count($dates); $i++) 
     
    472472  LIMIT '.$max_elements.' 
    473473;'; 
    474       $dates[$i]['elements'] = array_from_query($query); 
     474      $dates[$i]['elements'] = query2array($query); 
    475475    } 
    476476 
     
    490490  LIMIT '.$max_cats.' 
    491491;'; 
    492       $dates[$i]['categories'] = array_from_query($query); 
     492      $dates[$i]['categories'] = query2array($query); 
    493493    } 
    494494  } 
Note: See TracChangeset for help on using the changeset viewer.