Changeset 25427


Ignore:
Timestamp:
11/10/13 18:03:25 (6 years ago)
Author:
mistic100
Message:

move array_from_query to functions.inc.php

Location:
trunk/include
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/dblayer/functions_mysql.inc.php

    r25018 r25427  
    201201 */ 
    202202 
    203 /** 
    204  * creates an array based on a query, this function is a very common pattern 
    205  * used here 
    206  * 
    207  * @param string $query 
    208  * @param string $fieldname optional 
    209  * @return array 
    210  */ 
    211 function array_from_query($query, $fieldname=false) 
    212 { 
    213   $array = array(); 
    214  
    215   $result = pwg_query($query); 
    216   if (false === $fieldname) 
    217   { 
    218     while ($row = mysql_fetch_assoc($result)) 
    219     { 
    220       $array[] = $row;       
    221     } 
    222   } 
    223   else 
    224   { 
    225     while ($row = mysql_fetch_assoc($result)) 
    226     { 
    227       $array[] = $row[$fieldname]; 
    228     } 
    229   } 
    230   return $array; 
    231 } 
    232  
    233203define('MASS_UPDATES_SKIP_EMPTY', 1); 
    234204/** 
  • trunk/include/dblayer/functions_mysqli.inc.php

    r25018 r25427  
    238238 */ 
    239239 
    240 /** 
    241  * creates an array based on a query, this function is a very common pattern 
    242  * used here 
    243  * 
    244  * @param string $query 
    245  * @param string $fieldname optional 
    246  * @return array 
    247  */ 
    248 function array_from_query($query, $fieldname=false) 
    249 { 
    250   $array = array(); 
    251  
    252   $result = pwg_query($query); 
    253   if (false === $fieldname) 
    254   { 
    255     while ($row = pwg_db_fetch_assoc($result)) 
    256     { 
    257       $array[] = $row;       
    258     } 
    259   } 
    260   else 
    261   { 
    262     while ($row = pwg_db_fetch_assoc($result)) 
    263     { 
    264       $array[] = $row[$fieldname]; 
    265     } 
    266   } 
    267   return $array; 
    268 } 
    269  
    270240define('MASS_UPDATES_SKIP_EMPTY', 1); 
    271241/** 
  • trunk/include/functions.inc.php

    r25426 r25427  
    13151315 
    13161316/** 
     1317 * creates a numeric array based on a SQL query. 
     1318 * if _$fieldname_ is empty the returned value will be an array of arrays 
     1319 * if _$fieldname_ is provided the returned value will be a one dimension array 
     1320 * 
     1321 * @param string $query 
     1322 * @param string $fieldname 
     1323 * @return array 
     1324 */ 
     1325function array_from_query($query, $fieldname=false) 
     1326{ 
     1327  $array = array(); 
     1328 
     1329  $result = pwg_query($query); 
     1330  if (false === $fieldname) 
     1331  { 
     1332    while ($row = pwg_db_fetch_assoc($result)) 
     1333    { 
     1334      $array[] = $row;       
     1335    } 
     1336  } 
     1337  else 
     1338  { 
     1339    while ($row = pwg_db_fetch_assoc($result)) 
     1340    { 
     1341      $array[] = $row[$fieldname]; 
     1342    } 
     1343  } 
     1344  return $array; 
     1345} 
     1346 
     1347/** 
    13171348 * Return the basename of the current script. 
    13181349 * The lowercase case filename of the current script without extension 
Note: See TracChangeset for help on using the changeset viewer.