mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
Prerequisite for #1334. New API: DBObjectSet::SetOrderByClasses. Helper to sort on multicolumn queries (SELECT a, b FROM)
SVN:trunk[4413]
This commit is contained in:
@@ -445,8 +445,8 @@ class DBObjectSet
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the sort order for loading the rows from the DB. Changing the order by causes a Reload.
|
* Sets the sort order for loading the rows from the DB. Changing the order by causes a Reload.
|
||||||
*
|
*
|
||||||
* @param hash $aOrderBy Format: field_code => boolean (true = ascending, false = descending)
|
* @param hash $aOrderBy Format: [alias.]attcode => boolean (true = ascending, false = descending)
|
||||||
*/
|
*/
|
||||||
public function SetOrderBy($aOrderBy)
|
public function SetOrderBy($aOrderBy)
|
||||||
{
|
{
|
||||||
@@ -461,6 +461,34 @@ class DBObjectSet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the sort order for loading the rows from the DB. Changing the order by causes a Reload.
|
||||||
|
*
|
||||||
|
* @param hash $aAliases Format: alias => boolean (true = ascending, false = descending). If omitted, then it defaults to all the selected classes
|
||||||
|
*/
|
||||||
|
public function SetOrderByClasses($aAliases = null)
|
||||||
|
{
|
||||||
|
if ($aAliases === null)
|
||||||
|
{
|
||||||
|
$aAliases = array();
|
||||||
|
foreach ($this->GetSelectedClasses() as $sAlias => $sClass)
|
||||||
|
{
|
||||||
|
$aAliases[$sAlias] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$aAttributes = array();
|
||||||
|
foreach ($aAliases as $sAlias => $bClassDirection)
|
||||||
|
{
|
||||||
|
foreach (MetaModel::GetOrderByDefault($this->m_oFilter->GetClass($sAlias)) as $sAttCode => $bAttributeDirection)
|
||||||
|
{
|
||||||
|
$bDirection = $bClassDirection ? $bAttributeDirection : !$bAttributeDirection;
|
||||||
|
$aAttributes[$sAlias.'.'.$sAttCode] = $bDirection;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->SetOrderBy($aAttributes);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the 'count' limit for loading the rows from the DB
|
* Returns the 'count' limit for loading the rows from the DB
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user