【问题标题】:Find prefix cms in mysql DB在 mysql DB 中查找前缀 cms
【发布时间】:2023-03-31 10:27:01
【问题描述】:

我想从 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]."_"

;

【问题讨论】:

    标签: php mysql content-management-system


    【解决方案1】:

    如下尝试

    $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]."_"
    

    【讨论】:

      猜你喜欢
      • 2011-08-24
      • 2023-03-27
      • 1970-01-01
      • 2011-01-28
      • 1970-01-01
      • 2015-10-21
      • 2015-12-05
      • 1970-01-01
      • 2013-07-14
      相关资源
      最近更新 更多