我想从 CMS 的数据库中获取前缀。
我编写了这段代码,但是当数据库中有更多 CMS(Joomla、Opencart、Wordpress)或进行备份时,它不起作用。我可以更优雅地访问前缀吗?
$this->connectDB();
$result = mysql_query("show tables;");
while($row = mysql_fetch_row($result)){
$allRows[] = $row[0];
}
$index = preg_grep("/^.+_user$/", $allRows);
$pieces = explode("_", array_pop($index));
$this->_prefix=$pieces[0]."_"
;
最佳答案
尝试如下
$this->connectDB();
$result = mysql_query("show tables;");
while($row = mysql_fetch_row($result)){
$allRows[] = $row;
}
$index = preg_grep("/^.+_user$/", $allRows);
$pieces = explode("_", array_pop($index));
$this->_prefix=$pieces[0]."_"
关于php - 在mysql数据库中查找前缀cms,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29174617/