mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-06-02 04:15:05 +02:00
move array_from_query to functions.inc.php
git-svn-id: http://piwigo.org/svn/trunk@25427 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
@@ -1313,6 +1313,37 @@ function hash_from_query($query, $keyname)
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a numeric array based on a SQL query.
|
||||
* if _$fieldname_ is empty the returned value will be an array of arrays
|
||||
* if _$fieldname_ is provided the returned value will be a one dimension array
|
||||
*
|
||||
* @param string $query
|
||||
* @param string $fieldname
|
||||
* @return array
|
||||
*/
|
||||
function array_from_query($query, $fieldname=false)
|
||||
{
|
||||
$array = array();
|
||||
|
||||
$result = pwg_query($query);
|
||||
if (false === $fieldname)
|
||||
{
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
$array[] = $row;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
$array[] = $row[$fieldname];
|
||||
}
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the basename of the current script.
|
||||
* The lowercase case filename of the current script without extension
|
||||
|
||||
Reference in New Issue
Block a user