pdo查询重复更新,然后两个删除的错误

时间:2018-07-01 05:10:49

标签: php mysql sql pdo

尝试对两个表进行重复更新和删除时执行SQL查询。

  1. 这有效,但只有第一个删除无效,第二个被忽略。

    $sqlSalesOrderUpdate = $handler->prepare("
    INSERT INTO tv_sales_orders (sales_order_id, order_number) 
    VALUES (:sales_order_id, :order_number)
    ON DUPLICATE KEY 
    UPDATE sales_order_id=:sales_order_id;
    DELETE FROM `tv_sales_orders_lines` WHERE sales_order_id=:sales_order_id;
    DELETE FROM `tv_sales_orders_packing_list_lines` WHERE 
    tv_sales_order=:sales_order_id;
                                    ") ;
    
  2. 在加入后显示:

      

    带有消息“ SQLSTATE [HY093]”的异常“ PDOException”:C:\ xampp5.5 \ htdocs \ php \ index.php:4882中的无效跟踪号:绑定变量数与令牌数不匹配堆栈跟踪: #0

    $sqlSalesOrderUpdate = $handler->prepare("
    INSERT INTO tv_sales_orders (sales_order_id, order_number) 
    VALUES (:sales_order_id, :order_number)
    ON DUPLICATE KEY 
    UPDATE sales_order_id=:sales_order_id;
    DELETE FROM `tv_sales_orders_lines` WHERE sales_order_id=:sales_order_id;
    DELETE a.*, b.* 
    FROM tv_sales_orders_lines as a, tv_sales_orders_packing_list_lines as b 
    WHERE a.sales_order_id =:sales_orders_id and b.tv_sales_order_id=:sales_orders_id ;
    

0 个答案:

没有答案