yii\redis\ActiveQuery::all PHP 메소드

all() 공개 메소드

Executes the query and returns all results as an array.
public all ( Connection $db = null ) : array | yii\redis\ActiveRecord[]
$db Connection the database connection used to execute the query. If this parameter is not given, the `db` application component will be used.
리턴 array | yii\redis\ActiveRecord[] the query results. If the query results in nothing, an empty array will be returned.
    public function all($db = null)
    {
        // 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)) {
            $models = $this->createModels($rows);
            if (!empty($this->with)) {
                $this->findWith($this->with, $models);
            }
            if (!$this->asArray) {
                foreach ($models as $model) {
                    $model->afterFind();
                }
            }
            return $models;
        } else {
            return [];
        }
    }