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


PHP ActiveRecord::getModel方法代码示例

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


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

示例1: delete

 public static function delete(ActiveRecord $Record)
 {
     $modelName = $Record->getModel()->name;
     $primaryKey = $Record->getPrimaryKey();
     $pool =& self::$_pool;
     unset($pool[$modelName][$primaryKey]);
 }
开发者ID:imsamurai,项目名称:active-record-for-cakephp,代码行数:7,代码来源:ActiveRecordManager.php

示例2: __construct

 public function __construct($name, ActiveRecord $Record, $type, $definition, $record, $checkRecord)
 {
     $this->_AssociationStrategy = ActiveRecordAssociationType::create($type, $this);
     $this->_name = $name;
     $this->_Association = new ActiveRecordAssociationCollection($this);
     $this->_Record = $Record;
     $this->_type = $type;
     $this->_Model = $Record->getModel()->{$name};
     $this->_definition = $definition;
     $this->_associated = array();
     if (isset($record[$name])) {
         $this->_initializeWithRecord($record[$name], $checkRecord);
     }
 }
开发者ID:imsamurai,项目名称:active-record-for-cakephp,代码行数:14,代码来源:ActiveRecordAssociation.php

示例3: 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

示例4: associatedRecords

 public function associatedRecords(ActiveRecord $Record)
 {
     $referenceRecord = $Record->getRecord();
     $referenceModel = $Record->getModel();
     $relatedRecords = array();
     if (isset($referenceRecord[$referenceModel->primaryKey])) {
         if (!$referenceModel->Behaviors->attached('Containable')) {
             $referenceModel->Behaviors->load('Containable');
         }
         // We can never be sure that all records are stored in the pool. So we must query them.
         $result = $referenceModel->find('first', array('conditions' => array($referenceModel->alias . '.' . $referenceModel->primaryKey => $referenceRecord[$referenceModel->primaryKey]), 'contain' => array($this->_Association->getName()), 'activeRecord' => false));
         if (!$result) {
             return $relatedRecords;
         }
         foreach ($result[$this->_Association->getName()] as $relatedRecord) {
             $relatedRecords[] = ActiveRecordManager::getActiveRecord($this->_Association->getModel(), $relatedRecord);
         }
     }
     return $relatedRecords;
 }
开发者ID:imsamurai,项目名称:active-record-for-cakephp,代码行数:20,代码来源:ActiveRecordAssociationType.php


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