Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在mysql数据库中查找前缀cms_Php_Mysql_Content Management System - Fatal编程技术网

Php 在mysql数据库中查找前缀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]

我想从CMS的数据库中获取前缀。
我编写了这段代码,但如果在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]."_"