Skip to content

Commit 6513ec0

Browse files
committed
Fix example - arranging in order
1 parent 36e806f commit 6513ec0

File tree

1 file changed

+6
-7
lines changed
  • user_guide_src/source/database/query_builder

1 file changed

+6
-7
lines changed

user_guide_src/source/database/query_builder/092.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,17 @@
2626
->onConstraint(['`mytable`.`title`' => '`u`.`title`', 'author' => new RawSql('`u`.`author`')])
2727
->updateBatch();
2828

29-
// OR
30-
$builder->setData($data)
31-
->setAlias('u')
32-
->onConstraint(new RawSql('`mytable`.`title` = `u`.`title` AND `mytable`.`author` = `u`.`author`'))
33-
->updateFields(['last_update' => new RawSql('CURRENT_TIMESTAMP()')], true)
34-
->updateBatch();
35-
3629
// OR
3730
foreach ($data as $row) {
3831
$builder->setData($row);
3932
}
4033
$builder->onConstraint('title, author')->updateBatch();
34+
35+
// OR
36+
$builder->setData($data, true, 'u')
37+
->onConstraint(new RawSql('`mytable`.`title` = `u`.`title` AND `mytable`.`author` = `u`.`author`'))
38+
->updateFields(['last_update' => new RawSql('CURRENT_TIMESTAMP()')], true)
39+
->updateBatch();
4140
/*
4241
* Produces:
4342
* UPDATE `mytable`

0 commit comments

Comments
 (0)