当前位置: 首页>>代码示例>>PHP>>正文


PHP Tinebase_Record_RecordSet::getIdLessIndexes方法代码示例

本文整理汇总了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');
 }
开发者ID:rodrigofns,项目名称:ExpressoLivre3,代码行数:11,代码来源:RecordSetTest.php

示例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;
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:51,代码来源:RecordSet.php


注:本文中的Tinebase_Record_RecordSet::getIdLessIndexes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。