Tag Archives: prestashop

[Solved] Prestashop Install Warning: “PHP message: PHP Fatal error: Call to a member function fetch() on boolean

In the past two days, I have nothing to do. I searched for a good open source e-commerce platform to learn the source code. I searched GitHub and found that prestashop has a good reputation. So I downloaded it and tried it on centos7

Things went well all the time, but when the configuration page reached the fourth page, the database test was completed, and after clicking next, the page became blank

After flipping through the log, the prompt is: 2016/08/25 15:29:15 [error] 9054#0: * 52633 fastcgi send in stderr: “PHP message: PHP fatal error: call to a member function fetch() on Boolean in/usr/local/openrest/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 ”
it’s embarrassing. I don’t know what the hell it is, because I can’t understand PHP

However, this is not in the way. Looking for the dbpdo.php file, we can see the code with the problem:

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;
    }

What’s wrong is in line 9: $row = $result – > fetch();

Although I don’t understand PHP, I understand that it needs to get its results after executing the SQL statement above. The log prompt is that the function fetch() has a fatal error, but this is the system’s own function. How can it make an error, and it is still the Boolean value returned?That possibility should be $result itself is not correct, that is, the result of the SQL statement execution is not correct

Log in to MySQL and experiment with the command line: Show variables where variable_ name = ‘have_ innodb’;

Sure enough, the prompt is wrong: table ‘performance_ schema.session_ variables’ doesn’t exist

This problem is easy to solve. Just perform the following two steps:

mysql_upgrade -u root -p password --force
systemctl restart mysqld