Skip to content

Commit 6fce356

Browse files
committed
Data import now support dbprefix
1 parent db29334 commit 6fce356

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/libs/Xiidea/Installer/Services/DataBase.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,24 @@ public function parseMysqlDump($url)
104104
continue;
105105
}
106106

107-
mysql_query($query) or $error[] = mysql_error();
107+
mysql_query($this->addTablePrefix($query)) or $error[] = mysql_error();
108108
}
109109
}
110110

111+
private function addTablePrefix($query)
112+
{
113+
if (empty(self::$config['dbprefix'])) {
114+
return $query;
115+
}
116+
117+
return preg_replace(
118+
'/(insert into|for the table|for table|CREATE TABLE|DROP TABLE IF EXISTS) `([\w]+)`/',
119+
'${1} `' . self::$config['dbprefix'] .'${2}`',
120+
$query
121+
);
122+
123+
}
124+
111125
function splitQueryText($query)
112126
{
113127
// the regex needs a trailing semicolon

0 commit comments

Comments
 (0)