Пример #1
0
 public function one($db = null)
 {
     if (($result = parent::one($db)) === false) {
         return null;
     }
     if ($this->asArray) {
         return $result;
     } else {
         /* @var $class \yii\parse\ActiveRecord */
         $class = $this->modelClass;
         $model = $class::instantiate($result);
         $class::populateRecord($model, $result);
         if (!empty($this->with)) {
             $models = [$model];
             $this->findWith($this->with, $models);
             $model = $models[0];
         }
         $model->afterFind();
         return $model;
     }
 }