For example,
php
$params = [];
$sql = $queryBuilder->update('user', ['status' => 1], 'age > 30', $params);
The method will properly escape the table and column names.
public update ( string $table, array $columns, array | string $condition, array &$params ) : string | ||
$table | string | the table 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 DB command later. |
Результат | string | the UPDATE SQL |