yii\sphinx\QueryBuilder::update PHP Метод

update() публичный Метод

For example, php $params = []; $sql = $queryBuilder->update('idx_user', ['status' => 1], 'age > 30', $params); The method will properly escape the index and column names.
public update ( string $index, array $columns, array | string $condition, array &$params, array $options ) : string
$index string the index to be updated.
$columns array the column data (name => value) to be updated.
$condition array | string the condition that will be put in the WHERE part. Please refer to [[Query::where()]] on how to specify condition.
$params array the binding parameters that will be modified by this method so that they can be bound to the Sphinx command later.
$options array list of options in format: optionName => optionValue
Результат string the UPDATE SQL
    public function update($index, $columns, $condition, &$params, $options)
    {
        if (($indexSchema = $this->db->getIndexSchema($index)) !== null) {
            $indexSchemas = [$indexSchema];
        } else {
            $indexSchemas = [];
        }
        $lines = [];
        foreach ($columns as $name => $value) {
            $lines[] = $this->db->quoteColumnName($name) . '=' . $this->composeColumnValue($indexSchemas, $name, $value, $params);
        }
        $sql = 'UPDATE ' . $this->db->quoteIndexName($index) . ' SET ' . implode(', ', $lines);
        $where = $this->buildWhere([$index], $condition, $params);
        if ($where !== '') {
            $sql = $sql . ' ' . $where;
        }
        $option = $this->buildOption($options, $params);
        if ($option !== '') {
            $sql = $sql . ' ' . $option;
        }
        return $sql;
    }