mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-08 19:42:15 +09:00
Support ON DUPLICATE KEY UPDATE (upsert) queries
This commit is contained in:
parent
7f8312ee1a
commit
6f0ecd26a7
2 changed files with 30 additions and 7 deletions
|
|
@ -21,6 +21,7 @@ class Query extends VariableBase
|
|||
public $groupby = null;
|
||||
public $navigation = null;
|
||||
public $select_distinct = false;
|
||||
public $update_duplicate = false;
|
||||
|
||||
/**
|
||||
* Attributes for query generation.
|
||||
|
|
@ -229,6 +230,17 @@ class Query extends VariableBase
|
|||
}
|
||||
$result .= ' SET ' . implode(', ', $columns);
|
||||
|
||||
// Process the ON DUPLICATE KEY UPDATE (upsert) clause.
|
||||
if ($this->update_duplicate && count($columns))
|
||||
{
|
||||
$result .= ' ON DUPLICATE KEY UPDATE ' . implode(', ', $columns);
|
||||
$duplicate_params = $this->_params;
|
||||
foreach ($duplicate_params as $param)
|
||||
{
|
||||
$this->_params[] = $param;
|
||||
}
|
||||
}
|
||||
|
||||
// Return the final query string.
|
||||
return $result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue