mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-09 12:02:24 +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
|
|
@ -80,13 +80,6 @@ class DBQueryParser
|
|||
}
|
||||
|
||||
// Load columns.
|
||||
if ($xml->columns && $select_distinct = trim($xml->columns['distinct']))
|
||||
{
|
||||
if ($select_distinct === 'distinct' || toBool($select_distinct))
|
||||
{
|
||||
$query->select_distinct = true;
|
||||
}
|
||||
}
|
||||
foreach ($xml->columns->column as $tag)
|
||||
{
|
||||
if ($tag->getName() === 'query')
|
||||
|
|
@ -181,6 +174,24 @@ class DBQueryParser
|
|||
$query->columns[] = $column;
|
||||
}
|
||||
|
||||
// Check the SELECT DISTINCT flag.
|
||||
if ($xml->columns && $select_distinct = trim($xml->columns['distinct']))
|
||||
{
|
||||
if ($select_distinct === 'distinct' || toBool($select_distinct))
|
||||
{
|
||||
$query->select_distinct = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check the ON DUPLICATE KEY UPDATE (upsert) flag.
|
||||
if ($query->type === 'INSERT' && $update_duplicate = trim($xml['update_duplicate'] ?: $xml['update-duplicate']))
|
||||
{
|
||||
if (toBool($update_duplicate))
|
||||
{
|
||||
$query->update_duplicate = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Return the complete query definition.
|
||||
return $query;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue