mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 13:58:55 +08:00
@ -472,6 +472,13 @@ class Command extends Component
|
|||||||
* $connection->createCommand()->update('user', ['status' => 1], 'age > 30')->execute();
|
* $connection->createCommand()->update('user', ['status' => 1], 'age > 30')->execute();
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
|
* or with using parameter binding for the condition:
|
||||||
|
*
|
||||||
|
* ```php
|
||||||
|
* $minAge = 30;
|
||||||
|
* $connection->createCommand()->update('user', ['status' => 1], 'age > :minAge', [':minAge' => $minAge])->execute();
|
||||||
|
* ```
|
||||||
|
*
|
||||||
* The method will properly escape the column names and bind the values to be updated.
|
* The method will properly escape the column names and bind the values to be updated.
|
||||||
*
|
*
|
||||||
* Note that the created command is not executed until [[execute()]] is called.
|
* Note that the created command is not executed until [[execute()]] is called.
|
||||||
@ -498,6 +505,13 @@ class Command extends Component
|
|||||||
* $connection->createCommand()->delete('user', 'status = 0')->execute();
|
* $connection->createCommand()->delete('user', 'status = 0')->execute();
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
|
* or with using parameter binding for the condition:
|
||||||
|
*
|
||||||
|
* ```php
|
||||||
|
* $status = 0;
|
||||||
|
* $connection->createCommand()->delete('user', 'status = :status', [':status' => $status])->execute();
|
||||||
|
* ```
|
||||||
|
*
|
||||||
* The method will properly escape the table and column names.
|
* The method will properly escape the table and column names.
|
||||||
*
|
*
|
||||||
* Note that the created command is not executed until [[execute()]] is called.
|
* Note that the created command is not executed until [[execute()]] is called.
|
||||||
|
|||||||
Reference in New Issue
Block a user