protected function afterFind() { $this->LastName = $this->name . '-' . $this->id; if ($this->getIsEavEnabled()) { if ($this->hasEavAttribute('datetimeSingle')) { $this->LastName .= '-' . $this->datetimeSingle; } $this->LastName .= '-' . 'eavEnabled'; } parent::afterFind(); }
public function testRemoveEavAttributeException2() { $model = new EavSet(); $this->setExpectedException('CException'); $model->removeEavAttribute(EavActiveRecord::model()); }
/** * Updates the primary key value of the given entity instance in the table that stores EAV attributes values. * @param EavActiveRecord $entity EavActiveRecord instance. * @return int Returns number of affected rows. * @since Version 1.0.1 */ public function updateEntityPrimaryKey(EavActiveRecord $entity) { return $this->updateAll(array('entity_id' => $entity->getPrimaryKey()), 'entity = :entity AND entity_id = :entity_id', array(':entity' => $entity->getEntity(), ':entity_id' => $entity->getOldPrimaryKey())); }
/** * Returns the static model of the specified AR class. * Please note that you should have this exact method in all your CActiveRecord descendants! * @param string $className active record class name. * @return Ad the static model class */ public static function model($className = __CLASS__) { return parent::model($className); }
/** * Sets the parameters about query caching. * This is a shortcut method to {@link CDbConnection::cache()}. * It changes the query caching parameter of the {@link dbConnection} instance. * @param integer $duration the number of seconds that query results may remain valid in cache. * If this is 0, the caching will be disabled. * @param CCacheDependency $dependency the dependency that will be used when saving the query results into cache. * @param integer $queryCount number of SQL queries that need to be cached after calling this method. Defaults to 1, * meaning that the next SQL query will be cached. * @return CActiveRecord the active record instance itself. * @since 1.1.7 */ public function cache($duration, $dependency = null, $queryCount = 1) { /** * Получаем "теги" для кеша */ $model = strtolower(get_class($this)); $module = $model === 'settings' && !empty($this->module_id) ? $this->module_id : strtolower($this->moduleID); /** * Если не указана зависимость, * выставляем тегирование */ if ($dependency === null) { return parent::cache($duration, new TagsCache($model, $module), $queryCount); } elseif ($dependency instanceof TagsCache) { return parent::cache($duration, $dependency, $queryCount); } /** * Если же есть зависимость, * создаём цепочку и в неё добавляем * нужную зависимость + тегирование */ $chain = new CChainedCacheDependency(); $chain->dependencies->add($dependency); $chain->dependencies->add(new TagsCache($model, $module)); return parent::cache($duration, $chain, $queryCount); }