code: public function one($db = null)
      {
          if ($this->emulateExecution) {
              return null;
          }
  
          // TODO add support for orderBy
          $data = $this->executeScript($db, 'One');
          if (empty($data)) {
              return null;
          }
          $row = [];
          $c = count($data);
          for ($i = 0; $i < $c;) {
              $row[$data[$i++]] = $data[$i++];
          }
          if ($this->asArray) {
              $model = $row;
          } else {
              /* @var $class ActiveRecord */
              $class = $this->modelClass;
              $model = $class::instantiate($row);
              $class = get_class($model);
              $class::populateRecord($model, $row);
          }
          if (!empty($this->with)) {
              $models = [$model];
              $this->findWith($this->with, $models);
              $model = $models[0];
          }
          if (!$this->asArray) {
              $model->afterFind();
          }
  
          return $model;
      }
docs: Executes the query and returns a single row of result.
  @param Connection $db the database connection used to execute the query.
  If this parameter is not given, the `db` application component will be used.
  @return ActiveRecord|array|null a single row of query result. Depending on the setting of [[asArray]],
  the query result may be either an array or an ActiveRecord object. Null will be returned
  if the query results in nothing.