Skip to content

Commit

Permalink
Fix for CotDB::runScript to support custom table names set in confi…
Browse files Browse the repository at this point in the history
…g.php. A part of #1301.
  • Loading branch information
trustmaster committed Jan 4, 2014
1 parent 913d93f commit fa56caa
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions system/database.php
Expand Up @@ -503,9 +503,17 @@ public function runScript($script)
$query = trim($query);
if (!empty($query))
{
if ($db_x != 'cot_')
if ($db_x != 'cot_' && preg_match('#`cot_(\w+)`#', $query, $mt))
{
$query = str_replace('`cot_', '`'.$db_x, $query);
if (isset($GLOBALS['db_' . $mt[1]]))
{
$table_name = $GLOBALS['db_' . $mt[1]];
$query = str_replace($mt[0], "`$table_name`", $query);
}
else
{
$query = str_replace('`cot_', '`'.$db_x, $query);
}
}
$result = $this->query($query);
if (!$result)
Expand Down

0 comments on commit fa56caa

Please sign in to comment.