mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-02 01:52:10 +09:00
Fix #1442 add prefixes to INSERT/UPDATE queries, too
This commit is contained in:
parent
627f05c077
commit
2a87c060b9
2 changed files with 49 additions and 4 deletions
|
|
@ -933,10 +933,18 @@ class DB
|
|||
}
|
||||
else
|
||||
{
|
||||
return preg_replace_callback('/(FROM|JOIN)\s+((?:`?\w+\`?)(?:\s+AS\s+`?\w+`?)?(?:\s*,\s*(?:`?\w+\`?)(?:\s+AS\s+`?\w+`?)?)*)/i', function($m) {
|
||||
$tables = array_map(function($str) {
|
||||
return preg_replace_callback('/`?(\w+)`?(?:\s+AS\s+`?(\w+)`?)?/i', function($m) {
|
||||
return isset($m[2]) ? sprintf('`%s%s` AS `%s`', $this->_prefix, $m[1], $m[2]) : sprintf('`%s%s` AS `%s`', $this->_prefix, $m[1], $m[1]);
|
||||
return preg_replace_callback('/((?:DELETE\s+)?FROM|JOIN|INTO|UPDATE)(?i)\s+((?:`?\w+\`?)(?:\s+AS\s+`?\w+`?)?(?:\s*,\s*(?:`?\w+\`?)(?:\s+AS\s+`?\w+`?)?)*)/', function($m) {
|
||||
$type = strtoupper($m[1]);
|
||||
$tables = array_map(function($str) use($type) {
|
||||
return preg_replace_callback('/`?(\w+)`?(?:\s+AS\s+`?(\w+)`?)?/i', function($m) use($type) {
|
||||
if ($type === 'FROM' || $type === 'JOIN')
|
||||
{
|
||||
return isset($m[2]) ? sprintf('`%s%s` AS `%s`', $this->_prefix, $m[1], $m[2]) : sprintf('`%s%s` AS `%s`', $this->_prefix, $m[1], $m[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return sprintf('`%s%s`', $this->_prefix, $m[1]);
|
||||
}
|
||||
}, trim($str));
|
||||
}, explode(',', $m[2]));
|
||||
return $m[1] . ' ' . implode(', ', $tables);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue