Allow object creation from a mysql resource, allow objectGetEntries() to limit the range of

entries requested, this will be necessary for future performance optimizations
This commit is contained in:
Alexander Nicolaysen Sørnes
2007-02-01 02:06:38 +00:00
committed by WineHQ
parent fa111ec39d
commit cbdce75b0b

View File

@@ -18,20 +18,21 @@ class distribution {
var $aTestingIds; var $aTestingIds;
// constructor, fetches the data. // constructor, fetches the data.
function distribution($iDistributionId = null) function distribution($iDistributionId = null, $oRow = null)
{ {
// we are working on an existing distribution. // we are working on an existing distribution.
if(is_numeric($iDistributionId)) if(is_numeric($iDistributionId))
{ {
// We fetch the data related to this distribution. // We fetch the data related to this distribution.
if(!$this->$iDistributionId) if(!$oRow)
{ {
$sQuery = "SELECT * $sQuery = "SELECT *
FROM distributions FROM distributions
WHERE distributionId = '?'"; WHERE distributionId = '?'";
if($hResult = query_parameters($sQuery, $iDistributionId)) if($hResult = query_parameters($sQuery, $iDistributionId))
{
$oRow = mysql_fetch_object($hResult); $oRow = mysql_fetch_object($hResult);
}
if($oRow) if($oRow)
{ {
$this->iDistributionId = $iDistributionId; $this->iDistributionId = $iDistributionId;
@@ -42,8 +43,6 @@ class distribution {
$this->iSubmitterId = $oRow->submitterId; $this->iSubmitterId = $oRow->submitterId;
$this->sQueued = $oRow->queued; $this->sQueued = $oRow->queued;
} }
}
}
/* /*
* We fetch Test Result Ids. * We fetch Test Result Ids.
@@ -438,30 +437,26 @@ class distribution {
echo html_tr($aCells, $sClass); echo html_tr($aCells, $sClass);
} }
function objectGetEntries($bQueued) function objectGetEntries($bQueued, $iRows = 0, $iStart = 0)
{
if($bQueued)
{
if(distribution::canEdit())
{ {
/* Only users with edit privileges are allowed to view queued /* Only users with edit privileges are allowed to view queued
items, so return NULL in that case */ items, so return NULL in that case */
$sQuery = "SELECT distributionId FROM distributions if($bQueued && !distribution::canEdit())
WHERE queued = '?' ORDER BY name";
return query_parameters($sQuery, $bQueued ? "true" : "false");
} else
return NULL; return NULL;
} else
{ if(!$iRows)
$sQuery = "SELECT distributionId FROM distributions $iRows = distribution::getNumberOfDistributions($bQueued);
WHERE queued = '?' ORDER BY name";
return query_parameters($sQuery, "false"); $sQuery = "SELECT * FROM distributions
} WHERE queued = '?' ORDER BY name LIMIT ?,?";
return query_parameters($sQuery, $bQueued ? "true" : "false",
$iStart, $iRows);
} }
function ObjectGetInstanceFromRow($oRow) function objectGetInstanceFromRow($oRow)
{ {
return new distribution($oRow->distributionId); return new distribution($oRow->distributionId, $oRow);
} }
function objectOutputTableRow($sClass = "") function objectOutputTableRow($sClass = "")