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


PHP ActiveRecord::getRecord方法代码示例

本文整理汇总了PHP中ActiveRecord::getRecord方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecord::getRecord方法的具体用法?PHP ActiveRecord::getRecord怎么用?PHP ActiveRecord::getRecord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ActiveRecord的用法示例。


在下文中一共展示了ActiveRecord::getRecord方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: associatedRecords

 public function associatedRecords(ActiveRecord $Record)
 {
     $referenceRecord = $Record->getRecord();
     $foreignKey = $this->_Association->getDefinition('foreignKey');
     if (is_null($referenceRecord[$foreignKey])) {
         return array(null);
     }
     // The record has a foreign key, but has not the associated Active Record.
     // First try to find the Active Record in the pool, if not query it.
     $relatedRecord = ActiveRecordManager::findActiveRecordInPool($this->_Association->getModel(), $referenceRecord[$foreignKey]);
     if ($relatedRecord === false) {
         $relatedRecord = $this->_Association->getModel()->find('first', array('conditions' => array($this->_Association->getPrimaryKey() => $referenceRecord[$foreignKey]), 'recursive' => -1, 'activeRecord' => false));
         if ($relatedRecord) {
             $relatedRecord = ActiveRecordManager::getActiveRecord($this->_Association->getModel(), $relatedRecord);
         } else {
             $relatedRecord = null;
         }
     }
     return array($relatedRecord);
 }
开发者ID:imsamurai,项目名称:active-record-for-cakephp,代码行数:20,代码来源:ActiveRecordAssociationBelongsTo.php

示例2: associatedRecords

 public function associatedRecords(ActiveRecord $Record)
 {
     $record = $Record->getRecord();
     $Model = $Record->getModel();
     $RelatedRecord = false;
     // If the association has no condition, try first to find it in the pool
     if ($this->_Association->getDefinition('conditions')) {
         $RelatedRecord = ActiveRecordManager::findActiveRecordInPoolWithSecondaryKey($this->_Association->getModel(), $this->_Association->getDefinition('foreignKey'), $record[$Model->primaryKey]);
     }
     if ($RelatedRecord !== false) {
         return array($RelatedRecord);
     }
     if (!$Model->Behaviors->attached('Containable')) {
         $Model->Behaviors->load('Containable');
     }
     $result = $Model->find('first', array('conditions' => array($Model->alias . '.' . $Model->primaryKey => $record[$Model->primaryKey]), 'contain' => array($this->_Association->getName()), 'activeRecord' => false));
     if (!empty($result[$this->_Association->getName()][$this->_Association->getPrimaryKey()])) {
         $RelatedRecord = ActiveRecordManager::getActiveRecord($this->_Association->getModel(), $result[$this->_Association->getName()]);
     } else {
         $RelatedRecord = null;
     }
     return array($RelatedRecord);
 }
开发者ID:imsamurai,项目名称:active-record-for-cakephp,代码行数:23,代码来源:ActiveRecordAssociationHasOne.php

示例3: removeAssociatedRecord

 public function removeAssociatedRecord(ActiveRecord $Record, $resetKeys = true)
 {
     $checked = false;
     $record =& $Record->getRecord();
     foreach ($this->_associated as $key => $AssociatedRecord) {
         $associatedRecord =& $AssociatedRecord->getRecord();
         if ($associatedRecord === $record) {
             $checked = true;
             break;
         }
     }
     if (!$checked) {
         return;
     }
     unset($this->_associated[$key]);
     $this->_AssociationStrategy->removeAssociatedRecord($Record);
     if ($resetKeys) {
         $this->_associated = array_values($this->_associated);
     }
     $this->_changed = true;
 }
开发者ID:imsamurai,项目名称:active-record-for-cakephp,代码行数:21,代码来源:ActiveRecordAssociation.php

示例4: _removeOldAssociation

 /**
  * if the record is associated with another record and this record 
  * not the same as referenced record: find this record, and remove the association
  * 
  * @see AssociationsTest::testCrossAssociation
  * 
  * @param ActiveRecord $Record
  * @param ActiveRecord $ReferenceRecord
  * @param string $foreignKey
  * @return void
  */
 protected function _removeOldAssociation(ActiveRecord $Record, ActiveRecord $ReferenceRecord, $foreignKey)
 {
     $foreignKeyValue = $Record->getRecord()[$foreignKey];
     if (empty($foreignKeyValue)) {
         return;
     }
     $AssociatedRecord = ActiveRecordManager::findActiveRecordInPool($this->_Association->getRecord()->getModel(), $foreignKeyValue);
     if (!$AssociatedRecord || $ReferenceRecord === $AssociatedRecord) {
         return;
     }
     $assoctiation = $AssociatedRecord->{$this->_Association->getName()};
     if ($assoctiation) {
         $assoctiation->remove($Record);
     }
 }
开发者ID:imsamurai,项目名称:active-record-for-cakephp,代码行数:26,代码来源:ActiveRecordAssociationType.php


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