本文整理汇总了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]);
}
示例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);
}
}
示例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);
}
示例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;
}