yii\redis\ActiveQuery::executeScript PHP Метод

executeScript() защищенный Метод

Executes a script created by [[LuaScriptBuilder]]
protected executeScript ( Connection | null $db, string $type, string $columnName = null ) : array | boolean | null | string
$db Connection | null the database connection used to execute the query. If this parameter is not given, the `db` application component will be used.
$type string the type of the script to generate
$columnName string
Результат array | boolean | null | string
    protected function executeScript($db, $type, $columnName = null)
    {
        if ($this->primaryModel !== null) {
            // lazy loading
            if ($this->via instanceof self) {
                // via junction table
                $viaModels = $this->via->findJunctionRows([$this->primaryModel]);
                $this->filterByModels($viaModels);
            } elseif (is_array($this->via)) {
                // via relation
                /* @var $viaQuery ActiveQuery */
                list($viaName, $viaQuery) = $this->via;
                if ($viaQuery->multiple) {
                    $viaModels = $viaQuery->all();
                    $this->primaryModel->populateRelation($viaName, $viaModels);
                } else {
                    $model = $viaQuery->one();
                    $this->primaryModel->populateRelation($viaName, $model);
                    $viaModels = $model === null ? [] : [$model];
                }
                $this->filterByModels($viaModels);
            } else {
                $this->filterByModels([$this->primaryModel]);
            }
        }
        if (!empty($this->orderBy)) {
            throw new NotSupportedException('orderBy is currently not supported by redis ActiveRecord.');
        }
        /* @var $modelClass ActiveRecord */
        $modelClass = $this->modelClass;
        if ($db === null) {
            $db = $modelClass::getDb();
        }
        // find by primary key if possible. This is much faster than scanning all records
        if (is_array($this->where) && (!isset($this->where[0]) && $modelClass::isPrimaryKey(array_keys($this->where)) || isset($this->where[0]) && $this->where[0] === 'in' && $modelClass::isPrimaryKey($this->where[1]))) {
            return $this->findByPk($db, $type, $columnName);
        }
        $method = 'build' . $type;
        $script = $db->getLuaScriptBuilder()->{$method}($this, $columnName);
        return $db->executeCommand('EVAL', [$script, 0]);
    }