diff --git a/framework/db/Command.php b/framework/db/Command.php index dc360e37fa..21ec2bf9ae 100644 --- a/framework/db/Command.php +++ b/framework/db/Command.php @@ -472,6 +472,13 @@ class Command extends Component * $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. * * 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(); * ``` * + * 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. * * Note that the created command is not executed until [[execute()]] is called.