本文整理汇总了PHP中Tinebase_Record_RecordSet::getIdLessIndexes方法的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Record_RecordSet::getIdLessIndexes方法的具体用法?PHP Tinebase_Record_RecordSet::getIdLessIndexes怎么用?PHP Tinebase_Record_RecordSet::getIdLessIndexes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tinebase_Record_RecordSet
的用法示例。
在下文中一共展示了Tinebase_Record_RecordSet::getIdLessIndexes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testOffsetUnset
/**
* testOffsetUnset().
*/
public function testOffsetUnset()
{
unset($this->object[1]);
unset($this->object[3]);
$this->assertEquals(2, count($this->object));
$this->assertEquals(array(0), $this->object->getIdLessIndexes(), 'wrong idLess indexes');
$this->assertEquals(array(1), $this->object->getArrayOfIds(), 'wrong idFull indexes');
}
示例2: diff
/**
* compares two recordsets / only compares the ids / returns all records that are different in an array:
* - removed -> all records that are in $this but not in $_recordSet
* - added -> all records that are in $_recordSet but not in $this
* - modified -> array of diffs for all different records that are in both record sets
*
* @param Tinebase_Record_RecordSet $recordSet
* @return Tinebase_Record_RecordSetDiff
*/
public function diff($recordSet)
{
if (!$recordSet instanceof Tinebase_Record_RecordSet) {
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Did not get Tinebase_Record_RecordSet, skipping diff(' . $this->_recordClass . ')');
}
return new Tinebase_Record_RecordSetDiff(array('model' => $this->getRecordClassName()));
}
if ($this->getRecordClassName() !== $recordSet->getRecordClassName()) {
throw new Tinebase_Exception_InvalidArgument('can only compare recordsets with the same type of records');
}
$existingRecordsIds = $this->getArrayOfIds();
$toCompareWithRecordsIds = $recordSet->getArrayOfIds();
$removedIds = array_diff($existingRecordsIds, $toCompareWithRecordsIds);
$addedIds = array_diff($toCompareWithRecordsIds, $existingRecordsIds);
$modifiedIds = array_intersect($existingRecordsIds, $toCompareWithRecordsIds);
$removed = new Tinebase_Record_RecordSet($this->getRecordClassName());
$added = new Tinebase_Record_RecordSet($this->getRecordClassName());
$modified = new Tinebase_Record_RecordSet('Tinebase_Record_Diff');
foreach ($addedIds as $id) {
$added->addRecord($recordSet->getById($id));
}
// consider records without id, too
foreach ($recordSet->getIdLessIndexes() as $index) {
$added->addRecord($recordSet->getByIndex($index));
}
foreach ($removedIds as $id) {
$removed->addRecord($this->getById($id));
}
// consider records without id, too
foreach ($this->getIdLessIndexes() as $index) {
$removed->addRecord($this->getByIndex($index));
}
foreach ($modifiedIds as $id) {
$diff = $this->getById($id)->diff($recordSet->getById($id));
if (!$diff->isEmpty()) {
$modified->addRecord($diff);
}
}
$result = new Tinebase_Record_RecordSetDiff(array('model' => $this->getRecordClassName(), 'added' => $added, 'removed' => $removed, 'modified' => $modified));
return $result;
}