php - OpenCart中MySQL查询代码语法错误

标签 php mysql syntax opencart

我不知道为什么会出错:

Fatal error: Uncaught Exception: Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '* FROM mydatabase_customer SET status='0' WHERE customer_id='11'' at line 1
Error No: 1064
INSERT INTO * FROM mydatabase_customer SET status='0' WHERE customer_id='11' in /home/nedas/domains/mypage.com/public_html/opencart/system/library/db/mysqli.php:40 Stack trace: #0 /home/nedas/domains/mypage.com/public_html/opencart/system/library/db.php(45): DB\MySQLi->query('INSERT INTO * F...') #1 /home/nedas/domains/mypage.com/public_html/opencart/catalog/controller/account/success.php(29): DB->query('INSERT INTO * F...') #2 /home/nedas/domains/mypage.com/public_html/opencart/system/engine/action.php(79): ControllerAccountSuccess->index() #3 /home/nedas/domains/mypage.com/public_html/opencart/catalog/controller/startup/router.php(25): Action->execute(Object(Registry)) #4 /home/nedas/domains/mypage.com/public_html/opencart/system/eng in /home/nedas/domains/mypage.com/public_html/opencart/system/library/db/mysqli.php on line 40

我的代码:

        if ($this->customer->isLogged()) {
        $status = '0';
        $id = $this->customer->getId();
        $this->db->query("INSERT INTO * FROM perkulenkijoje_customer SET status='$status' WHERE customer_id='$id'");
        echo ("Info: Insert done");
    } else {
        echo ("Info: Please log in");
    }

请帮助我。

如何使用opencart平台成功插入数据库?

最佳答案

要保留 opencart 数据库结构(我的意思是前缀),您需要使用这样的查询

$this->db->query("UPDATE " . DB_PREFIX . "perkulenkijoje_customer SET status = '" . (int)$status . "' WHERE customer_id = '" . (int)$id . "'");

如果将此查询移至模型文件并在 Controller 中调用它,效果会更好。

关于php - OpenCart中MySQL查询代码语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54439666/

相关文章:

php - Mysql查询奇怪失败

php - 使用 XHR 取消 PHP 脚本?

php - 如果我绑定(bind)参数,我必须使用 mysql_real_escape_string 吗?

ruby - Ruby 中的语句 block

php - Laravel Homestead 中 PHP 错误日志的位置

javascript - 使用 javascript 将井号标签分隔值替换为逗号分隔值

javascript - php显示当前页面

mysql - 组合两个不同列的 Select 语句

c# - BufferedImage 从 Java 到 C# 的等价物

c++ - 点运算符和点运算符有什么意义?