Php 在mysql数据库中查找前缀cms
我想从CMS的数据库中获取前缀。Php 在mysql数据库中查找前缀cms,php,mysql,content-management-system,Php,Mysql,Content Management System,我想从CMS的数据库中获取前缀。 我编写了这段代码,但如果在db中有更多的CMS(Joomla、Opencart、Wordpress)或进行备份,它就不起作用了。我可以更优雅地访问前缀吗 $this->connectDB(); $result = mysql_query("show tables;"); while($row = mysql_fetch_row($result)){ $allRows[] = $row[0]
我编写了这段代码,但如果在db中有更多的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]."_"