Beispiel #1
0
 /**
  * Executes query and returns all results as an array.
  *
  * @param Connection $db      the DB connection used to create the DB command.
  *                            If null, the DB connection returned by [[modelClass]] will be used.
  * @param array      $options Options that will be passed to search command
  *
  * @return array the query results. If the query results in nothing, an empty array will be returned.
  */
 public function all($db = null, $options = [])
 {
     if ($this->asArray) {
         // TODO implement with
         return parent::all($db);
     }
     $result = $this->createCommand($db)->search($options);
     if (empty($result)) {
         return [];
     }
     $models = $this->createModels($result);
     if (!empty($this->with)) {
         $this->findWith($this->with, $models);
     }
     foreach ($models as $model) {
         $model->afterFind();
     }
     return $models;
 }
Beispiel #2
0
 /**
  * Executes query and returns all results as an array.
  *
  * @param Connection $db the DB connection used to create the DB command.
  *                            If null, the DB connection returned by [[modelClass]] will be used.
  *
  * @return array the query results. If the query results in nothing, an empty array will be returned.
  */
 public function all($db = null)
 {
     if ($this->asArray) {
         // TODO implement with
         return parent::all($db);
     }
     $rows = $this->createCommand($db)->search($this->options);
     return $this->populate($rows);
 }