douzhen5158 2014-03-14 05:35
浏览 36
已采纳

PHP PDO多重准备声明

This Code did not work. I am new in php pdo. This statement works only for first stmp then other does not work.

Code:

try {   
    $db->beginTransaction();

    $stmp = $db->prepare("UPDATE jeslot_customer SET cust_outstinding=:totaloutstanding WHERE cust_name=:custname");
    $stmp->execute(array(':totaloutstanding' => $tout,':custname' => $custname));

    $stmp1 = $db->prepare("UPDATE jeslot_products SET opening_stock=:clstock WHERE product_name=:name1");
    $stmp1->execute(array(':clstock' => $clstock,':name1' => $name1));


    $stmt2 = $db->prepare('INSERT INTO jeslot_sales (username, sell_date, invoiceid, product_name, product_weight, sell_price, sell_qty, sell_freeqty, totalqty, sell_amount, customerid, customer_name, subtotal, discount, dis_amount, grandtotal, payment, balance, due_date, payment_mode, cheque_no, cheque_bank, description, countid, profitloss) VALUES (:uname, :selldate, :invoice ,:sname, :pkg, :srate, :sqty, :sfreeqty, :totalqty, :samount, :custid, :custname, :subtotal, :discount, :dis_amount, :payable, :payment, :balance, :duedate, :payment_mode, :cno, :bname, :description, :countid, :profit)');

    $stmt2->execute(array(
    ':uname' => $username,
    ':selldate' => $selldate,
    ':invoice' => $bill_no,
    ':sname' => $name1,
    ':pkg' => $pkg,
    ':srate' => $rate,
    ':sqty' => $quantity,
    ':sfreeqty' => $freequantity,
    ':totalqty' => $totalqty,
    ':samount' => $total,
    ':custid' => $custid,
    ':custname' => $custname,
    ':subtotal' => $subtotal,
    ':discount' => $discount,
    ':dis_amount' => $dis_amount,
    ':payable' => $grandtotal,
    ':payment' => $payment,
    ':balance' => $balance,
    ':duedate' => $duedate,
    ':payment_mode' => $mode,
    ':cno' => $cno,
    ':bname' => $bname,
    ':description' => $description,
    ':countid' => ($i+1),
    ':profit' => $profit
    ));

    $db->commit();
    $db->rollback();

} catch(PDOException $e) {

    $error[] = $e->getMessage();
}
  • 写回答

2条回答 默认 最新

  • dsy48837 2014-03-14 05:42
    关注

    Should not this statement

    $stmp1->execute(array(':clstock' => $clstock,':name1' => $name1));
    

    be

    $stmp1->execute(array(':clstock' => $clstock,':product_name' => $name1));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥35 MIMO天线稀疏阵列排布问题
  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?