code: public function all($db = null)
      {
          if ($this->emulateExecution) {
              return [];
          }
  
          // TODO add support for orderBy
          $data = $this->executeScript($db, 'All');
          if (empty($data)) {
              return [];
          }
          $rows = [];
          foreach ($data as $dataRow) {
              $row = [];
              $c = count($dataRow);
              for ($i = 0; $i < $c;) {
                  $row[$dataRow[$i++]] = $dataRow[$i++];
              }
  
              $rows[] = $row;
          }
          if (empty($rows)) {
              return [];
          }
  
          $models = $this->createModels($rows);
          if (!empty($this->with)) {
              $this->findWith($this->with, $models);
          }
          if ($this->indexBy !== null) {
              $indexedModels = [];
              if (is_string($this->indexBy)) {
                  foreach ($models as $model) {
                      $key = $model[$this->indexBy];
                      $indexedModels[$key] = $model;
                  }
              } else {
                  foreach ($models as $model) {
                      $key = call_user_func($this->indexBy, $model);
                      $indexedModels[$key] = $model;
                  }
              }
              $models = $indexedModels;
          }
          if (!$this->asArray) {
              foreach ($models as $model) {
                  $model->afterFind();
              }
          }
  
          return $models;
      }
docs: Executes the query and returns all results as an array.
  @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 array|ActiveRecord[] the query results. If the query results in nothing, an empty array will be returned.