服务报价 | 域名主机 | 网络营销 | 软件工具| [加入收藏]
 热线电话: #
当前位置: 主页 > php教程 > prestashop教程 >

安装prestashop提示"PHP message: PHP Fatal error: Call to a member function fetch() on boolean

时间:2016-09-10 12:26来源:未知 作者:最模板 点击:
安装prestashop日志,提示:2016/08/25 15:29:15 [error] 9054#0: *52633 FastCGI sent in stderr: PHP message: PHP Fatal error: Call to a member function fetch() on boolean in /usr/local/openresty/nginx/html/prestashop/classes/db/DbPDO.p

  安装prestashop日志,提示:2016/08/25 15:29:15 [error] 9054#0: *52633 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Call to a member function fetch() on boolean in /usr/local/openresty/nginx/html/prestashop/classes/db/DbPDO.php on line 371" while reading response header from upstream, client: 123.98.11.90, server: gm.kimoon.cn, request: "POST /install/index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "gm.kimoon.cn", referrer: "http://gm.kimoon.cn/install/index.php"
    这下就尴尬了,完全不知道是什么鬼,因为我不会PHP…

    不过这并不碍事,找了DbPDO.php这个文件看,出问题的那一段代码:

public function getBestEngine()
    {
        $value = 'InnoDB';

        $sql = 'SHOW VARIABLES WHERE Variable_name = \'have_innodb\'';
        $result = $this->link->query($sql);
        if (!$result) {
            $value = 'MyISAM';
        }
        $row = $result->fetch();
        if (!$row || strtolower($row['Value']) != 'yes') {
            $value = 'MyISAM';
        }

        /* MySQL >= 5.6 */
        $sql = 'SHOW ENGINES';
        $result = $this->link->query($sql);
        while ($row = $result->fetch()) {
            if ($row['Engine'] == 'InnoDB') {
                if (in_array($row['Support'], array('DEFAULT', 'YES'))) {
                    $value = 'InnoDB';
                }
                break;
            }
        }

        return $value;
    }

出问题的是第九行的:$row = $result->fetch();

    虽然我不懂PHP,但是大概意思还是明白,它是执行了上面那个sql语句之后,需要获取它的结果。而日志提示是函数fetch()出现致命错误,但是这个是系统自带函数,怎么可能会出错呢,而且还是返回的布尔值?那可能性应该$result本身就不正确,也就是那个sql语句执行的结果不对!

    登录进去mysql,用命令行实验了下:SHOW VARIABLES WHERE Variable_name = 'have_innodb';

    果不其然,提示出错了:Table 'performance_schema.session_variables' doesn't exist

    这个问题好解决,执行下面两步即可:

mysql_upgrade -u root -p password --force
systemctl restart mysqld
(责任编辑:最模板)
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------