本文整理汇总了PHP中CActiveRecordBehavior::afterFind方法的典型用法代码示例。如果您正苦于以下问题:PHP CActiveRecordBehavior::afterFind方法的具体用法?PHP CActiveRecordBehavior::afterFind怎么用?PHP CActiveRecordBehavior::afterFind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CActiveRecordBehavior
的用法示例。
在下文中一共展示了CActiveRecordBehavior::afterFind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: afterFind
public function afterFind($event)
{
if ($this->getAttribute() !== NULL) {
$this->_value = $this->getOwner()->getAttribute($this->getAttribute());
}
return parent::afterFind($event);
}
示例2: afterFind
public function afterFind($event)
{
parent::afterFind($event);
//это не открывать, работает для всех взаимосвязанных элементов
// if(!Common::isCLI() && ($history = request()->getParam('history')) ){
// $this->getFullHistory($history);
// }
}
示例3: afterFind
/**
* Decripts the values of specified attributes after finding from database
* @param CEvent $event
* @return parent::afterFind
*/
public function afterFind($event)
{
foreach ($this->getOwner()->getAttributes() as $key => $value) {
if (in_array($key, $this->attributes) && !empty($value)) {
if ($this->useAESMySql) {
$this->getOwner()->{$key} = $this->mysqlAESDecrypt($value, Yii::app()->securityManager->getEncryptionKey());
} else {
$this->getOwner()->{$key} = Yii::app()->securityManager->decrypt(utf8_decode($value));
}
}
}
return parent::afterFind($event);
}
示例4: afterFind
public function afterFind($event)
{
$owner = $this->getOwner();
foreach ($this->attributes as $attr) {
if (isset($owner->{$attr})) {
$date = new DateTime($owner->{$attr});
$date->setTimezone(new DateTimeZone(Yii::app()->controller->timezone));
$owner->setAttribute($attr, $date->format('Y-m-d H:i:s'));
} else {
//throw exception
}
}
parent::afterFind($event);
}
示例5: afterFind
/**
* Converts ISO 9075 dates to $dateFormat after read from database
*/
public function afterFind($event)
{
foreach ($this->dateColumns as $date) {
$_dt = $this->Owner->{$date};
if (preg_match("/([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})/", $_dt, $regs)) {
$_dt = $regs[3] . "/" . $regs[2] . "/" . $regs[1];
}
if ($_dt == '00/00/0000') {
$this->Owner->{$date} = '';
} else {
$this->Owner->{$date} = $_dt;
}
}
return parent::afterFind($event);
}
示例6: afterFind
public function afterFind($event)
{
foreach ($this->attributes as $attribute => $format) {
if (!$this->owner->hasAttribute($attribute)) {
continue;
}
$format = $format == null ? self::FORMAT_DEFAULT : $format;
if ($this->owner->getAttribute($attribute) == '0') {
$this->attributes[$attribute] = $this->emptyMark;
} else {
$this->attributes[$attribute] = Yii::app()->dateFormatter->format($format, $this->owner->getAttribute($attribute));
}
}
$this->owner->setAttributes($this->attributes);
parent::afterFind($event);
}
示例7: afterFind
/**
* Provides creating related HAS_ONE records in memory.
*
* @param CEvent $event event object
*
* @see CActiveRecordBehavior::afterFind()
*
* @throws Exception
*/
public function afterFind($event)
{
$owner = $this->getOwner();
foreach ($owner->relations() as $key => $relation) {
$isHasOne = $relation['0'] == CActiveRecord::HAS_ONE;
if (!$isHasOne) {
continue;
}
if (isset($this->relations[$key]) || in_array($key, $this->relations)) {
$config = $this->_getRelationConfig($key);
if ($config['createRelated']) {
$criteria = new CDbCriteria();
$parameters = array_slice($relation, self::RELATION_REQUIRED_PARAMS_COUNT);
foreach ($parameters as $name => $value) {
$name = $name == 'on' ? 'condition' : $name;
$criteria->{$name} = $value;
}
$criteria->compare($relation[2], $owner->primaryKey);
$model = CActiveRecord::model($relation[1]);
if (!$model->exists($criteria)) {
$related = new $relation[1]();
$related->{$relation}[2] = $owner->primaryKey;
if ($config['insertIfNotExists']) {
if (!$related->save(false)) {
$message = 'Can not save related record. ' . CHtml::errorSummary($related);
throw new CException($message);
}
}
$this->owner->addRelatedRecord($key, $related, false);
}
}
}
}
parent::afterFind($event);
}
示例8: afterFind
public function afterFind($event)
{
if ($this->owner->findMode === TActiveRecord::FIND_ONE) {
foreach ($this->config as $item) {
$prefix = $item['prefix'];
$type = $item['type'];
$privArray = $this->getPriv($type);
foreach ($privArray as $scope => $value) {
$this->owner->{$prefix . $scope} = $value;
}
}
}
parent::afterFind($event);
}
示例9: afterFind
public function afterFind($event)
{
// Save old values
$this->setOldAttributes($this->Owner->getAttributes());
return parent::afterFind($event);
}
示例10: afterFind
/**
* Actions to be performed after the model is loaded
*/
public function afterFind($event)
{
$this->_dbAttributes = $this->owner->getAttributes();
parent::afterFind($event);
}
示例11: afterFind
/**
* Load status after find model.
* @param CEvent
*/
public function afterFind($event)
{
$this->_status = $this->getOwner()->getAttribute($this->statusField);
$this->_statusText = isset($this->statuses[$this->_status]) ? $this->statuses[$this->_status] : 'unknown';
parent::afterFind($event);
}
示例12: afterFind
public function afterFind($event)
{
$this->setOldAttributes($this->getOwner()->getAttributes());
return parent::afterFind($event);
}
示例13: afterFind
/**
* Apply object translation
*/
public function afterFind($event)
{
if (!$this->disableEvents) {
$this->applyTranslation();
}
return parent::afterFind($event);
}
示例14: afterFind
/**
* Apply object translation
*/
public function afterFind($event)
{
$this->_oldTags = $this->getOwner()->tags;
return parent::afterFind($event);
}
示例15: afterFind
/**
* @param CEvent $event
*/
public function afterFind($event)
{
$this->_convertAttributesFromDB();
parent::afterFind($event);
}