mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-21 17:48:43 +02:00
PHPDoc
SVN:trunk[5972]
This commit is contained in:
@@ -38,7 +38,7 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
*/
|
||||
protected $m_aAddedIds; // Ids of objects added (discrete lists)
|
||||
/**
|
||||
* @var hash array of (row => array of (classalias) => object/null) storing the objects added "in memory"
|
||||
* @var array array of (row => array of (classalias) => object/null) storing the objects added "in memory"
|
||||
*/
|
||||
protected $m_aAddedObjects;
|
||||
/**
|
||||
@@ -118,12 +118,19 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \CoreException
|
||||
* @throws \MissingQueryArgument
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
$sRet = '';
|
||||
$this->Rewind();
|
||||
$sRet .= "Set (".$this->m_oFilter->ToOQL().")<br/>\n";
|
||||
$sRet .= "Query: <pre style=\"font-size: smaller; display:inline;\">".$this->m_oFilter->MakeSelectQuery().")</pre>\n";
|
||||
$sRet .= "Query: <pre style=\"font-size: smaller; display:inline;\">".$this->m_oFilter->MakeSelectQuery().")</pre>\n";
|
||||
|
||||
$sRet .= $this->Count()." records<br/>\n";
|
||||
if ($this->Count() > 0)
|
||||
@@ -171,13 +178,16 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
return $this->m_oFilter->GetShowObsoleteData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the subset of attributes to load (for each class of objects) before performing the SQL query for retrieving the rows from the DB
|
||||
*
|
||||
* @param array $aAttToLoad Format: alias => array of attribute_codes
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Specify the subset of attributes to load (for each class of objects) before performing the SQL query for retrieving the rows from the DB
|
||||
*
|
||||
* @param array $aAttToLoad Format: alias => array of attribute_codes
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \CoreException
|
||||
*/
|
||||
public function OptimizeColumnLoad($aAttToLoad)
|
||||
{
|
||||
if (is_null($aAttToLoad))
|
||||
@@ -249,13 +259,15 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a set (in-memory) containing just the given object
|
||||
*
|
||||
* @param DBobject $oObject
|
||||
*
|
||||
* @return DBObjectSet The singleton set
|
||||
*/
|
||||
/**
|
||||
* Create a set (in-memory) containing just the given object
|
||||
*
|
||||
* @param \DBobject $oObject
|
||||
*
|
||||
* @return \DBObjectSet The singleton set
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
static public function FromObject($oObject)
|
||||
{
|
||||
$oRetSet = self::FromScratch(get_class($oObject));
|
||||
@@ -263,13 +275,15 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
return $oRetSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an empty set (in-memory), for the given class (and its subclasses) of objects
|
||||
*
|
||||
* @param string $sClass The class (or an ancestor) for the objects to be added in this set
|
||||
*
|
||||
* @return DBObjectSet The empty set
|
||||
*/
|
||||
/**
|
||||
* Create an empty set (in-memory), for the given class (and its subclasses) of objects
|
||||
*
|
||||
* @param string $sClass The class (or an ancestor) for the objects to be added in this set
|
||||
*
|
||||
* @return \DBObjectSet The empty set
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
static public function FromScratch($sClass)
|
||||
{
|
||||
$oFilter = new DBObjectSearch($sClass);
|
||||
@@ -278,34 +292,38 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
$oRetSet->m_bLoaded = true; // no DB load
|
||||
$oRetSet->m_iNumTotalDBRows = 0; // Nothing from the DB
|
||||
return $oRetSet;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a set (in-memory) with just one column (i.e. one object per row) and filled with the given array of objects
|
||||
*
|
||||
* @param string $sClass The class of the objects (must be a common ancestor to all objects in the set)
|
||||
* @param array $aObjects The list of objects to add into the set
|
||||
*
|
||||
* @return DBObjectSet
|
||||
*/
|
||||
/**
|
||||
* Create a set (in-memory) with just one column (i.e. one object per row) and filled with the given array of objects
|
||||
*
|
||||
* @param string $sClass The class of the objects (must be a common ancestor to all objects in the set)
|
||||
* @param array $aObjects The list of objects to add into the set
|
||||
*
|
||||
* @return \DBObjectSet
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
static public function FromArray($sClass, $aObjects)
|
||||
{
|
||||
$oRetSet = self::FromScratch($sClass);
|
||||
$oRetSet->AddObjectArray($aObjects, $sClass);
|
||||
return $oRetSet;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a set in-memory with several classes of objects per row (with one alias per "column")
|
||||
*
|
||||
* Limitation:
|
||||
* The filter/OQL query representing such a set can not be rebuilt (only the first column will be taken into account)
|
||||
*
|
||||
* @param hash $aClasses Format: array of (alias => class)
|
||||
* @param hash $aObjects Format: array of (array of (classalias => object))
|
||||
*
|
||||
* @return DBObjectSet
|
||||
*/
|
||||
/**
|
||||
* Create a set in-memory with several classes of objects per row (with one alias per "column")
|
||||
*
|
||||
* Limitation:
|
||||
* The filter/OQL query representing such a set can not be rebuilt (only the first column will be taken into account)
|
||||
*
|
||||
* @param array $aClasses Format: array of (alias => class)
|
||||
* @param array $aObjects Format: array of (array of (classalias => object))
|
||||
*
|
||||
* @return \DBObjectSet
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
static public function FromArrayAssoc($aClasses, $aObjects)
|
||||
{
|
||||
// In a perfect world, we should create a complete tree of DBObjectSearch,
|
||||
@@ -324,9 +342,19 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
$oRetSet->AddObjectExtended($aObjectsByClassAlias);
|
||||
}
|
||||
return $oRetSet;
|
||||
}
|
||||
}
|
||||
|
||||
static public function FromLinkSet($oObject, $sLinkSetAttCode, $sExtKeyToRemote)
|
||||
/**
|
||||
* @param $oObject
|
||||
* @param string $sLinkSetAttCode
|
||||
* @param string $sExtKeyToRemote
|
||||
*
|
||||
* @return \DBObjectSet
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \ArchivedObjectException
|
||||
* @throws \CoreException
|
||||
*/static public function FromLinkSet($oObject, $sLinkSetAttCode, $sExtKeyToRemote)
|
||||
{
|
||||
$oLinkAttCode = MetaModel::GetAttributeDef(get_class($oObject), $sLinkSetAttCode);
|
||||
$oExtKeyAttDef = MetaModel::GetAttributeDef($oLinkAttCode->GetLinkedClass(), $sExtKeyToRemote);
|
||||
@@ -346,7 +374,13 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
* Note: After calling this method, the set cursor will be at the end of the set. You might want to rewind it.
|
||||
*
|
||||
* @param bool $bWithId
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \CoreException
|
||||
* @throws \CoreUnexpectedValue
|
||||
* @throws \MySQLException
|
||||
*/
|
||||
public function ToArray($bWithId = true)
|
||||
{
|
||||
@@ -364,8 +398,16 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
}
|
||||
}
|
||||
return $aRet;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \CoreException
|
||||
* @throws \CoreUnexpectedValue
|
||||
* @throws \MySQLException
|
||||
*/
|
||||
public function ToArrayOfValues()
|
||||
{
|
||||
if (!$this->m_bLoaded) $this->Load();
|
||||
@@ -421,7 +463,11 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
*
|
||||
* @param string $sAttCode
|
||||
* @param bool $bWithId
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \CoreException
|
||||
*/
|
||||
public function GetColumnAsArray($sAttCode, $bWithId = true)
|
||||
{
|
||||
@@ -441,14 +487,16 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
return $aRet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the DBSearch corresponding to the objects present in this set
|
||||
*
|
||||
* Limitation:
|
||||
* This method will NOT work for sets with several columns (i.e. several objects per row)
|
||||
*
|
||||
* @return DBObjectSearch
|
||||
*/
|
||||
/**
|
||||
* Retrieve the DBSearch corresponding to the objects present in this set
|
||||
*
|
||||
* Limitation:
|
||||
* This method will NOT work for sets with several columns (i.e. several objects per row)
|
||||
*
|
||||
* @return \DBObjectSearch
|
||||
*
|
||||
* @throws \CoreException
|
||||
*/
|
||||
public function GetFilter()
|
||||
{
|
||||
// Make sure that we carry on the parameters of the set with the filter
|
||||
@@ -495,18 +543,20 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
/**
|
||||
* The list of all classes (one per column) which are part of this set
|
||||
*
|
||||
* @return hash Format: alias => class
|
||||
* @return array Format: alias => class
|
||||
*/
|
||||
public function GetSelectedClasses()
|
||||
{
|
||||
return $this->m_oFilter->GetSelectedClasses();
|
||||
}
|
||||
|
||||
/**
|
||||
* The root class (i.e. highest ancestor in the MeaModel class hierarchy) for the first column on this set
|
||||
*
|
||||
* @return string The root class for the objects in the first column of the set
|
||||
*/
|
||||
/**
|
||||
* The root class (i.e. highest ancestor in the MeaModel class hierarchy) for the first column on this set
|
||||
*
|
||||
* @return string The root class for the objects in the first column of the set
|
||||
*
|
||||
* @throws \CoreException
|
||||
*/
|
||||
public function GetRootClass()
|
||||
{
|
||||
return MetaModel::GetRootClass($this->GetClass());
|
||||
@@ -515,7 +565,7 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
/**
|
||||
* The arguments used for building this set
|
||||
*
|
||||
* @return hash Format: parameter_name => value
|
||||
* @return array Format: parameter_name => value
|
||||
*/
|
||||
public function GetArgs()
|
||||
{
|
||||
@@ -533,11 +583,13 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
$this->m_iLimitStart = $iLimitStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the sort order for loading the rows from the DB. Changing the order by causes a Reload.
|
||||
*
|
||||
* @param hash $aOrderBy Format: [alias.]attcode => boolean (true = ascending, false = descending)
|
||||
*/
|
||||
/**
|
||||
* Sets the sort order for loading the rows from the DB. Changing the order by causes a Reload.
|
||||
*
|
||||
* @param array $aOrderBy Format: [alias.]attcode => boolean (true = ascending, false = descending)
|
||||
*
|
||||
* @throws \MySQLException
|
||||
*/
|
||||
public function SetOrderBy($aOrderBy)
|
||||
{
|
||||
if ($this->m_aOrderBy != $aOrderBy)
|
||||
@@ -551,11 +603,14 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
/**
|
||||
* Sets the sort order for loading the rows from the DB. Changing the order by causes a Reload.
|
||||
*
|
||||
* @param array $aAliases Format: alias => boolean (true = ascending, false = descending). If omitted, then it defaults to all the selected classes
|
||||
*
|
||||
* @throws \CoreException
|
||||
* @throws \MySQLException
|
||||
*/
|
||||
public function SetOrderByClasses($aAliases = null)
|
||||
{
|
||||
if ($aAliases === null)
|
||||
@@ -599,13 +654,15 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
return $this->m_iLimitStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sort order used for loading this set from the database
|
||||
*
|
||||
* Limitation: the sort order has no effect on objects added in-memory
|
||||
*
|
||||
* @return array Format: field_code => boolean (true = ascending, false = descending)
|
||||
*/
|
||||
/**
|
||||
* Get the sort order used for loading this set from the database
|
||||
*
|
||||
* Limitation: the sort order has no effect on objects added in-memory
|
||||
*
|
||||
* @return array Format: field_code => boolean (true = ascending, false = descending)
|
||||
*
|
||||
* @throws \CoreException
|
||||
*/
|
||||
public function GetRealSortOrder()
|
||||
{
|
||||
if (!$this->m_bSort)
|
||||
@@ -625,9 +682,12 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the set from the database. Actually performs the SQL query to retrieve the records from the DB.
|
||||
*/
|
||||
/**
|
||||
* Loads the set from the database. Actually performs the SQL query to retrieve the records from the DB.
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \MySQLException
|
||||
*/
|
||||
public function Load()
|
||||
{
|
||||
if ($this->m_bLoaded) return;
|
||||
@@ -682,11 +742,14 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
$this->m_iNumLoadedDBRows = $this->m_oSQLResult->num_rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $aAttToLoad
|
||||
*
|
||||
* @return string SQL query
|
||||
*/
|
||||
/**
|
||||
* @param string[] $aAttToLoad
|
||||
*
|
||||
* @return string SQL query
|
||||
*
|
||||
* @throws \CoreException
|
||||
* @throws \MissingQueryArgument
|
||||
*/
|
||||
private function _makeSelectQuery($aAttToLoad)
|
||||
{
|
||||
if ($this->m_iLimitCount > 0)
|
||||
@@ -703,15 +766,20 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
return $sSQL;
|
||||
}
|
||||
|
||||
/**
|
||||
* The total number of rows in this set. Independently of the SetLimit used for loading the set and taking into
|
||||
* account the rows added in-memory.
|
||||
*
|
||||
* May actually perform the SQL query SELECT COUNT... if the set was not previously loaded, or loaded with a
|
||||
* SetLimit
|
||||
*
|
||||
* @return int The total number of rows for this set.
|
||||
*/
|
||||
/**
|
||||
* The total number of rows in this set. Independently of the SetLimit used for loading the set and taking into
|
||||
* account the rows added in-memory.
|
||||
*
|
||||
* May actually perform the SQL query SELECT COUNT... if the set was not previously loaded, or loaded with a
|
||||
* SetLimit
|
||||
*
|
||||
* @return int The total number of rows for this set.
|
||||
*
|
||||
* @throws \CoreException
|
||||
* @throws \MissingQueryArgument
|
||||
* @throws \MySQLException
|
||||
* @throws \MySQLHasGoneAwayException
|
||||
*/
|
||||
public function Count()
|
||||
{
|
||||
if (is_null($this->m_iNumTotalDBRows))
|
||||
@@ -732,6 +800,7 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
* @param $iLimit
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws \CoreException
|
||||
* @throws \MissingQueryArgument
|
||||
* @throws \MySQLException
|
||||
@@ -766,6 +835,7 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
* @param $iLimit
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @throws \CoreException
|
||||
* @throws \MissingQueryArgument
|
||||
* @throws \MySQLException
|
||||
@@ -806,12 +876,17 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
return $this->m_iNumLoadedDBRows + count($this->m_aAddedObjects);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the object (with the given class alias) at the current position in the set and move the cursor to the next position.
|
||||
*
|
||||
* @param string $sRequestedClassAlias The class alias to fetch (if there are several objects/classes per row)
|
||||
* @return DBObject The fetched object or null when at the end
|
||||
*/
|
||||
/**
|
||||
* Fetch the object (with the given class alias) at the current position in the set and move the cursor to the next position.
|
||||
*
|
||||
* @param string $sRequestedClassAlias The class alias to fetch (if there are several objects/classes per row)
|
||||
*
|
||||
* @return \DBObject The fetched object or null when at the end
|
||||
*
|
||||
* @throws \CoreException
|
||||
* @throws \CoreUnexpectedValue
|
||||
* @throws \MySQLException
|
||||
*/
|
||||
public function Fetch($sRequestedClassAlias = '')
|
||||
{
|
||||
if (!$this->m_bLoaded) $this->Load();
|
||||
@@ -855,11 +930,15 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
return $oRetObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the whole row of objects (if several classes have been specified in the query) and move the cursor to the next position
|
||||
*
|
||||
* @return hash A hash with the format 'classAlias' => $oObj representing the current row of the set. Returns null when at the end.
|
||||
*/
|
||||
/**
|
||||
* Fetch the whole row of objects (if several classes have been specified in the query) and move the cursor to the next position
|
||||
*
|
||||
* @return array An associative with the format 'classAlias' => $oObj representing the current row of the set. Returns null when at the end.
|
||||
*
|
||||
* @throws \CoreException
|
||||
* @throws \CoreUnexpectedValue
|
||||
* @throws \MySQLException
|
||||
*/
|
||||
public function FetchAssoc()
|
||||
{
|
||||
if (!$this->m_bLoaded) $this->Load();
|
||||
@@ -902,6 +981,8 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
|
||||
/**
|
||||
* Position the cursor (for iterating in the set) to the first position (equivalent to Seek(0))
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function Rewind()
|
||||
{
|
||||
@@ -911,11 +992,18 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Position the cursor (for iterating in the set) to the given position
|
||||
*
|
||||
* @param int $iRow
|
||||
*/
|
||||
/**
|
||||
* Position the cursor (for iterating in the set) to the given position
|
||||
*
|
||||
* @param int $iRow
|
||||
*
|
||||
* @return int|mixed
|
||||
*
|
||||
* @throws \CoreException
|
||||
* @throws \MissingQueryArgument
|
||||
* @throws \MySQLException
|
||||
* @throws \MySQLHasGoneAwayException
|
||||
*/
|
||||
public function Seek($iRow)
|
||||
{
|
||||
if (!$this->m_bLoaded) $this->Load();
|
||||
@@ -928,15 +1016,17 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
return $this->m_iCurrRow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an object to the current set (in-memory only, nothing is written to the database)
|
||||
*
|
||||
* Limitation:
|
||||
* Sets with several objects per row are NOT supported
|
||||
*
|
||||
* @param DBObject $oObject The object to add
|
||||
* @param string $sClassAlias The alias for the class of the object
|
||||
*/
|
||||
/**
|
||||
* Add an object to the current set (in-memory only, nothing is written to the database)
|
||||
*
|
||||
* Limitation:
|
||||
* Sets with several objects per row are NOT supported
|
||||
*
|
||||
* @param \DBObject $oObject The object to add
|
||||
* @param string $sClassAlias The alias for the class of the object
|
||||
*
|
||||
* @throws \MySQLException
|
||||
*/
|
||||
public function AddObject($oObject, $sClassAlias = '')
|
||||
{
|
||||
if (!$this->m_bLoaded) $this->Load();
|
||||
@@ -954,16 +1044,18 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a hash containig objects into the current set.
|
||||
*
|
||||
* The expected format for the hash is: $aObjectArray[$idx][$sClassAlias] => $oObject
|
||||
* Limitation:
|
||||
* The aliases MUST match the ones used in the current set
|
||||
* Only the ID of the objects associated to the first alias (column) is remembered.. in case we have to rebuild a filter
|
||||
*
|
||||
* @param hash $aObjectArray
|
||||
*/
|
||||
/**
|
||||
* Add a hash containig objects into the current set.
|
||||
*
|
||||
* The expected format for the hash is: $aObjectArray[$idx][$sClassAlias] => $oObject
|
||||
* Limitation:
|
||||
* The aliases MUST match the ones used in the current set
|
||||
* Only the ID of the objects associated to the first alias (column) is remembered.. in case we have to rebuild a filter
|
||||
*
|
||||
* @param array $aObjectArray
|
||||
*
|
||||
* @throws \MySQLException
|
||||
*/
|
||||
protected function AddObjectExtended($aObjectArray)
|
||||
{
|
||||
if (!$this->m_bLoaded) $this->Load();
|
||||
@@ -983,15 +1075,17 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an array of objects into the current set
|
||||
*
|
||||
* Limitation:
|
||||
* Sets with several classes per row are not supported (use AddObjectExtended instead)
|
||||
*
|
||||
* @param array $aObjects The array of objects to add
|
||||
* @param string $sClassAlias The Alias of the class for the added objects
|
||||
*/
|
||||
/**
|
||||
* Add an array of objects into the current set
|
||||
*
|
||||
* Limitation:
|
||||
* Sets with several classes per row are not supported (use AddObjectExtended instead)
|
||||
*
|
||||
* @param array $aObjects The array of objects to add
|
||||
* @param string $sClassAlias The Alias of the class for the added objects
|
||||
*
|
||||
* @throws \MySQLException
|
||||
*/
|
||||
public function AddObjectArray($aObjects, $sClassAlias = '')
|
||||
{
|
||||
if (!$this->m_bLoaded) $this->Load();
|
||||
@@ -1009,8 +1103,9 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
* Limitation:
|
||||
* The added objects are not checked for duplicates (i.e. one cann add several times the same object, or add an object already present in the set).
|
||||
*
|
||||
* @param DBObjectSet $oObjectSet The set to append
|
||||
* @throws CoreException
|
||||
* @param \DBObjectSet $oObjectSet The set to append
|
||||
*
|
||||
* @throws \CoreException
|
||||
*/
|
||||
public function Append(DBObjectSet $oObjectSet)
|
||||
{
|
||||
@@ -1027,17 +1122,24 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a set containing the objects present in both the current set and another specified set
|
||||
*
|
||||
* Limitations:
|
||||
* Will NOT work if only a subset of the sets was loaded with SetLimit.
|
||||
* Works only with sets made of objects loaded from the database since the comparison is based on the objects identifiers
|
||||
*
|
||||
* @param DBObjectSet $oObjectSet The set to intersect with. The current position inside the set will be lost (= at the end)
|
||||
* @throws CoreException
|
||||
* @return DBObjectSet A new set of objects, containing the objects present in both sets (based on their identifier)
|
||||
*/
|
||||
/**
|
||||
* Create a set containing the objects present in both the current set and another specified set
|
||||
*
|
||||
* Limitations:
|
||||
* Will NOT work if only a subset of the sets was loaded with SetLimit.
|
||||
* Works only with sets made of objects loaded from the database since the comparison is based on the objects identifiers
|
||||
*
|
||||
* @param \DBObjectSet $oObjectSet The set to intersect with. The current position inside the set will be lost (= at the end)
|
||||
*
|
||||
* @return \DBObjectSet A new set of objects, containing the objects present in both sets (based on their identifier)
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \CoreException
|
||||
* @throws \CoreUnexpectedValue
|
||||
* @throws \MissingQueryArgument
|
||||
* @throws \MySQLException
|
||||
* @throws \MySQLHasGoneAwayException
|
||||
*/
|
||||
public function CreateIntersect(DBObjectSet $oObjectSet)
|
||||
{
|
||||
if ($this->GetRootClass() != $oObjectSet->GetRootClass())
|
||||
@@ -1069,16 +1171,19 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
return $oNewSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two sets of objects to determine if their content is identical or not.
|
||||
*
|
||||
* Limitation:
|
||||
* Works only for sets of 1 column (i.e. one class of object selected)
|
||||
*
|
||||
* @param DBObjectSet $oObjectSet
|
||||
* @param array $aExcludeColumns The list of columns to exclude frop the comparison
|
||||
* @return boolean True if the sets are identical, false otherwise
|
||||
*/
|
||||
/**
|
||||
* Compare two sets of objects to determine if their content is identical or not.
|
||||
*
|
||||
* Limitation:
|
||||
* Works only for sets of 1 column (i.e. one class of object selected)
|
||||
*
|
||||
* @param \DBObjectSet $oObjectSet
|
||||
* @param array $aExcludeColumns The list of columns to exclude frop the comparison
|
||||
*
|
||||
* @return boolean True if the sets are identical, false otherwise
|
||||
*
|
||||
* @throws \CoreException
|
||||
*/
|
||||
public function HasSameContents(DBObjectSet $oObjectSet, $aExcludeColumns = array())
|
||||
{
|
||||
$oComparator = new DBObjectSetComparator($this, $oObjectSet, $aExcludeColumns);
|
||||
@@ -1092,10 +1197,12 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
* The objects inside the set must be written in the database since the comparison is based on their identifiers
|
||||
* Sets with several objects per row are NOT supported
|
||||
*
|
||||
* @param DBObjectSet $oObjectSet
|
||||
* @throws CoreException
|
||||
* @param \DBObjectSet $oObjectSet
|
||||
*
|
||||
* @return DBObjectSet The "delta" set.
|
||||
* @return \DBObjectSet The "delta" set.
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \CoreException
|
||||
*/
|
||||
public function CreateDelta(DBObjectSet $oObjectSet)
|
||||
{
|
||||
@@ -1128,9 +1235,11 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
return $oNewSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will be deprecated soon - use MetaModel::GetRelatedObjectsDown/Up instead to take redundancy into account
|
||||
*/
|
||||
/**
|
||||
* Will be deprecated soon - use MetaModel::GetRelatedObjectsDown/Up instead to take redundancy into account
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function GetRelatedObjects($sRelCode, $iMaxDepth = 99)
|
||||
{
|
||||
$aRelatedObjs = array();
|
||||
@@ -1154,16 +1263,21 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
return $aRelatedObjs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the "RelatedObjects" (forward or "down" direction) for the set
|
||||
* for the specified relation
|
||||
*
|
||||
* @param string $sRelCode The code of the relation to use for the computation
|
||||
* @param int $iMaxDepth Maximum recursion depth
|
||||
* @param boolean $bEnableReduncancy Whether or not to take into account the redundancy
|
||||
*
|
||||
* @return RelationGraph The graph of all the related objects
|
||||
*/
|
||||
/**
|
||||
* Compute the "RelatedObjects" (forward or "down" direction) for the set
|
||||
* for the specified relation
|
||||
*
|
||||
* @param string $sRelCode The code of the relation to use for the computation
|
||||
* @param int $iMaxDepth Maximum recursion depth
|
||||
* @param bool $bEnableRedundancy
|
||||
*
|
||||
* @return \RelationGraph The graph of all the related objects
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \CoreException
|
||||
* @throws \CoreUnexpectedValue
|
||||
* @throws \MySQLException
|
||||
*/
|
||||
public function GetRelatedObjectsDown($sRelCode, $iMaxDepth = 99, $bEnableRedundancy = true)
|
||||
{
|
||||
$oGraph = new RelationGraph();
|
||||
@@ -1175,17 +1289,22 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
$oGraph->ComputeRelatedObjectsDown($sRelCode, $iMaxDepth, $bEnableRedundancy);
|
||||
return $oGraph;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the "RelatedObjects" (reverse or "up" direction) for the set
|
||||
* for the specified relation
|
||||
*
|
||||
* @param string $sRelCode The code of the relation to use for the computation
|
||||
* @param int $iMaxDepth Maximum recursion depth
|
||||
* @param boolean $bEnableReduncancy Whether or not to take into account the redundancy
|
||||
*
|
||||
* @return RelationGraph The graph of all the related objects
|
||||
*/
|
||||
|
||||
/**
|
||||
* Compute the "RelatedObjects" (reverse or "up" direction) for the set
|
||||
* for the specified relation
|
||||
*
|
||||
* @param string $sRelCode The code of the relation to use for the computation
|
||||
* @param int $iMaxDepth Maximum recursion depth
|
||||
* @param bool $bEnableRedundancy
|
||||
*
|
||||
* @return \RelationGraph The graph of all the related objects
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \CoreException
|
||||
* @throws \CoreUnexpectedValue
|
||||
* @throws \MySQLException
|
||||
*/
|
||||
public function GetRelatedObjectsUp($sRelCode, $iMaxDepth = 99, $bEnableRedundancy = true)
|
||||
{
|
||||
$oGraph = new RelationGraph();
|
||||
@@ -1197,14 +1316,21 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
$oGraph->ComputeRelatedObjectsUp($sRelCode, $iMaxDepth, $bEnableRedundancy);
|
||||
return $oGraph;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds an object that contains the values that are common to all the objects
|
||||
* in the set. If for a given attribute, objects in the set have various values
|
||||
* then the resulting object will contain null for this value.
|
||||
* @param $aValues Hash Output: the distribution of the values, in the set, for each attribute
|
||||
* @return DBObject The object with the common values
|
||||
*/
|
||||
|
||||
/**
|
||||
* Builds an object that contains the values that are common to all the objects
|
||||
* in the set. If for a given attribute, objects in the set have various values
|
||||
* then the resulting object will contain null for this value.
|
||||
*
|
||||
* @param array $aValues Hash Output: the distribution of the values, in the set, for each attribute
|
||||
*
|
||||
* @return \DBObject The object with the common values
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \CoreException
|
||||
* @throws \CoreUnexpectedValue
|
||||
* @throws \MySQLException
|
||||
*/
|
||||
public function ComputeCommonObject(&$aValues)
|
||||
{
|
||||
$sClass = $this->GetClass();
|
||||
@@ -1288,7 +1414,7 @@ class DBObjectSet implements iDBObjectSetIterator
|
||||
|
||||
/**
|
||||
* List the constant fields (and their value) in the given query
|
||||
* @return Hash [Alias][AttCode] => value
|
||||
* @return array [Alias][AttCode] => value
|
||||
*/
|
||||
public function ListConstantFields()
|
||||
{
|
||||
@@ -1378,10 +1504,12 @@ class DBObjectSetComparator
|
||||
$this->oSet1 = $oSet1;
|
||||
$this->oSet2 = $oSet2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the lists of fingerprints and initializes internal structures, if it was not already done
|
||||
*/
|
||||
|
||||
/**
|
||||
* Builds the lists of fingerprints and initializes internal structures, if it was not already done
|
||||
*
|
||||
* @throws \CoreException
|
||||
*/
|
||||
protected function ComputeFingerprints()
|
||||
{
|
||||
if ($this->aFingerprints1 === null)
|
||||
@@ -1426,11 +1554,13 @@ class DBObjectSetComparator
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells if the sets are equivalent or not. Returns as soon as the first difference is found.
|
||||
* @return boolean true if the set have an equivalent content, false otherwise
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tells if the sets are equivalent or not. Returns as soon as the first difference is found.
|
||||
* @return boolean true if the set have an equivalent content, false otherwise
|
||||
*
|
||||
* @throws \CoreException
|
||||
*/
|
||||
public function SetsAreEquivalent()
|
||||
{
|
||||
if (($this->oSet1 === null) && ($this->oSet2 === null))
|
||||
@@ -1469,13 +1599,16 @@ class DBObjectSetComparator
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of differences between the two sets. In ordeer to write back into the database only the minimum changes
|
||||
* THE FIRST SET MUST BE THE ONE LOADED FROM THE DATABASE
|
||||
* Returns a hash: 'added' => DBObject(s), 'removed' => DBObject(s), 'modified' => DBObjects(s)
|
||||
* @return Ambigous <int:DBObject: , unknown>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get the list of differences between the two sets. In ordeer to write back into the database only the minimum changes
|
||||
* THE FIRST SET MUST BE THE ONE LOADED FROM THE DATABASE
|
||||
* Returns a hash: 'added' => DBObject(s), 'removed' => DBObject(s), 'modified' => DBObjects(s)
|
||||
* @return array
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \CoreException
|
||||
*/
|
||||
public function GetDifferences()
|
||||
{
|
||||
$aResult = array('added' => array(), 'removed' => array(), 'modified' => array());
|
||||
@@ -1524,13 +1657,19 @@ class DBObjectSetComparator
|
||||
}
|
||||
return $aResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helpr to clone (in memory) an object and to apply to it the values taken from a second object
|
||||
* @param DBObject $oObjToClone
|
||||
* @param DBObject $oObjWithValues
|
||||
* @return DBObject The modified clone
|
||||
*/
|
||||
|
||||
/**
|
||||
* Helpr to clone (in memory) an object and to apply to it the values taken from a second object
|
||||
*
|
||||
* @param \DBObject $oObjToClone
|
||||
* @param \DBObject $oObjWithValues
|
||||
*
|
||||
* @return \DBObject The modified clone
|
||||
*
|
||||
* @throws \ArchivedObjectException
|
||||
* @throws \CoreException
|
||||
* @throws \CoreUnexpectedValue
|
||||
*/
|
||||
protected function CopyFrom($oObjToClone, $oObjWithValues)
|
||||
{
|
||||
$oObj = MetaModel::GetObject(get_class($oObjToClone), $oObjToClone->GetKey());
|
||||
|
||||
Reference in New Issue
Block a user