我不知道为什么会出错:
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/