Merge some code to get list of Wine versions

This commit is contained in:
Alexander Nicolaysen Sørnes
2009-06-15 15:18:39 +02:00
parent b62ed3aab6
commit 70729a700c

View File

@@ -165,8 +165,10 @@ function get_xml_tag ($file, $mode = null)
/* bugzilla functions */ /* bugzilla functions */
// Returns an array containg the Wine versions stored in our Bugzilla DB // Returns an array containg the Wine versions stored in our Bugzilla DB
function get_bugzilla_versions() // If bReturnIds is true, version ids are returned instead of names
function get_bugzilla_versions($bReturnIds = false)
{ {
$sFetchColumn = $bReturnIds ? 'id' : 'value';
$aVersions = array(); $aVersions = array();
$sTable = BUGZILLA_DB.".versions"; $sTable = BUGZILLA_DB.".versions";
@@ -180,7 +182,7 @@ function get_bugzilla_versions()
foreach($aBranches as $sBranch) foreach($aBranches as $sBranch)
{ {
$sWhere = "WHERE product_id =".BUGZILLA_PRODUCT_ID." AND value LIKE '$sBranch%'"; $sWhere = "WHERE product_id =".BUGZILLA_PRODUCT_ID." AND value LIKE '$sBranch%'";
$sQuery = "SELECT value FROM $sTable $sWhere ORDER BY id desc limit 6"; $sQuery = "SELECT $sFetchColumn FROM $sTable $sWhere ORDER BY id desc limit 6";
$hResult = query_bugzilladb($sQuery); $hResult = query_bugzilladb($sQuery);
if($hResult) if($hResult)
{ {
@@ -198,18 +200,7 @@ function get_bugzilla_versions()
// Returns an array containing the IDs of the Wine versions stored in Bugzilla // Returns an array containing the IDs of the Wine versions stored in Bugzilla
function get_bugzilla_version_ids() function get_bugzilla_version_ids()
{ {
$aIds = array(); return get_bugzilla_versions(true);
$hResult = query_bugzilladb("SELECT id FROM ".BUGZILLA_DB.".versions WHERE
product_id = '".BUGZILLA_PRODUCT_ID."'
ORDER BY id DESC LIMIT 6");
if(!$hResult)
return $aIds;
while(list($sId) = mysql_fetch_row($hResult))
$aIds[] = $sId;
return $aIds;
} }
// $sVarname - name of the selection array that this function will output // $sVarname - name of the selection array that this function will output