Commit d3134514 by Alexander Makarov

Merge pull request #6960 from alexbs/patch-1

Update db-dao.md
parents bab2737f a77650ba
...@@ -190,8 +190,8 @@ executing it multiple times with different parameters. For example, ...@@ -190,8 +190,8 @@ executing it multiple times with different parameters. For example,
```php ```php
$command = $db->createCommand('SELECT * FROM post WHERE id=:id'); $command = $db->createCommand('SELECT * FROM post WHERE id=:id');
$post1 = $command->bindValue(':id', 1)->queryRow(); $post1 = $command->bindValue(':id', 1)->queryOne();
$post2 = $command->bindValue(':id', 2)->queryRow(); $post2 = $command->bindValue(':id', 2)->queryOne();
``` ```
Because [[yii\db\Command::bindParam()|bindParam()]] supports binding parameters by references, the above code Because [[yii\db\Command::bindParam()|bindParam()]] supports binding parameters by references, the above code
...@@ -202,10 +202,10 @@ $command = $db->createCommand('SELECT * FROM post WHERE id=:id') ...@@ -202,10 +202,10 @@ $command = $db->createCommand('SELECT * FROM post WHERE id=:id')
->bindParam(':id', $id); ->bindParam(':id', $id);
$id = 1; $id = 1;
$post1 = $command->queryRow(); $post1 = $command->queryOne();
$id = 2; $id = 2;
$post2 = $command->queryRow(); $post2 = $command->queryOne();
``` ```
Notice that you bind the placeholder to the `$id` variable before the execution, and then change the value of that variable Notice that you bind the placeholder to the `$id` variable before the execution, and then change the value of that variable
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment