Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
b2a734fd
Commit
b2a734fd
authored
Sep 27, 2008
by
Dries
Browse files
- Patch
#301501
by markus_petrux: optimize db_merge() in MySQL by taking advantage of ODKU syntax.
parent
42dda57f
Changes
1
Hide whitespace changes
Inline
Side-by-side
includes/database/mysql/query.inc
View file @
b2a734fd
...
...
@@ -81,11 +81,10 @@ public function execute() {
$update_fields
=
$this
->
updateFields
;
}
else
{
$update_fields
=
$this
->
insertFields
;
// If there are no exclude fields, this is a no-op.
foreach
(
$this
->
excludeFields
as
$exclude_field
)
{
unset
(
$update_fields
[
$exclude_field
]);
}
// When update fields are derived from insert fields, we don't need
// placeholders since we can tell MySQL to reuse insert supplied
// values using the VALUES(col_name) function.
$update_fields
=
array
();
}
$insert_fields
=
$this
->
insertFields
+
$this
->
keyFields
;
...
...
@@ -123,7 +122,6 @@ public function execute() {
public
function
__toString
()
{
// Set defaults.
$update_fields
=
array
();
if
(
$this
->
updateFields
)
{
$update_fields
=
$this
->
updateFields
;
}
...
...
@@ -157,8 +155,15 @@ public function __toString() {
unset
(
$update_fields
[
$field
]);
}
// Build update fields clauses based on caller supplied list, or derived
// from insert supplied values using the VALUES(col_name) function.
foreach
(
$update_fields
as
$field
=>
$value
)
{
$update
[]
=
(
$field
.
'=:db_update_placeholder_'
.
$max_placeholder
++
);
if
(
$this
->
updateFields
)
{
$update
[]
=
(
$field
.
'=:db_update_placeholder_'
.
$max_placeholder
++
);
}
else
{
$update
[]
=
(
$field
.
'=VALUES('
.
$field
.
')'
);
}
}
$query
.
=
implode
(
', '
,
$update
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment