Php 当我尝试插入到表中时,如何从何处修复错误?

Php 当我尝试插入到表中时,如何从何处修复错误?,php,mysql,codeigniter-3,Php,Mysql,Codeigniter 3,我想在用户售出商品后立即删除,但如果我的最终库存低于我的最低库存,那么它将从数据库在我的表上插入一个通知,但在使用node.js推送该通知之后,但当我尝试在售后服务中插入到我的表时,会显示这样的错误,我应该如何修复它 public function concretar_venta(){ if($this->sale->checa_carrito_vacio($this->session->carrito)){ $to

我想在用户售出商品后立即删除,但如果我的最终库存低于我的最低库存,那么它将从数据库在我的表上插入一个通知,但在使用node.js推送该通知之后,但当我尝试在售后服务中插入到我的表时,会显示这样的错误,我应该如何修复它

public function concretar_venta(){
            if($this->sale->checa_carrito_vacio($this->session->carrito)){
                $total = $this->input->post("total", TRUE);
                $cantidad_pagada = $this->input->post("cantidad_pagada", TRUE);
                $cambio = $cantidad_pagada - $total;
                if($this->sale->concretar_venta($this->session->carrito, $total, $cantidad_pagada, $cambio)){
                    $this->json(array('success' => 'The sale was successfully made'));
                }
                else{
                    $this->json(array('error' => 'There was an error making the sale, please try again'));
                }

                $this->session->carrito = $this->sale->checar_existe_carrito();
                $array = $this->sale->get_all_cart($this->session->carrito);
                $product_id = array();
                foreach ($array as $key => $value) {
                    $product_id[] = $value['id'];
                }

                $this->notification->addNotification('low stock', $product_id, $this->session->log['id'], 'low stock');

                /*if ($product->stock <= 8) {
                    $this->notification->addNotification('low stock', $product_id, $this->session->log['id'], 'low stock');
                } else {
                    # code...
                }*/

            }
            else{
                $this->json(array('error' => 'The cart is empty'));
            }
        }
错误输出:

错误号:1064您的SQL语法有错误;检查与您的MariaDB服务器版本相对应的手册,以了解在第1行使用near')和type=2'的正确语法,选择COUNT(*)作为storelte_通知中的notificationCount,其中product_id IN()和type=2文件名:C:/xampp/htdocs/storelte/system/database/DB_driver.php行号:691

IN()
需要一个产品标识字符串才能签入,因此需要将产品标识数组转换为字符串

在这些行之间:

 $timestamp = time();
 $query = "SELECT COUNT(*)...


IN()
需要参数,所以应该反勾选列名。看起来您正在尝试将数组
$product\u id
传递到单个参数中。那不行。你必须做一些操作,让它检查数组中的每个产品id。是的,它应该是我的模型pid,参数是$product_id[]=$value['id'];从控制器,我不知道错误来自哪里
 $timestamp = time();
 $query = "SELECT COUNT(*)...
 $timestamp = time();
 $product_id = implode(',',$product_id);//add this line
 $query = "SELECT COUNT(*)...