PHP PDO多重准备语句
PHP PDO Multiple Prepare Statement
此代码无效。我是新的php pdo。这个语句只适用于第一个邮票,然后其他不工作。
代码:
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();
}
这个语句不应该
$stmp1->execute(array(':clstock' => $clstock,':name1' => $name1));
$stmp1->execute(array(':clstock' => $clstock,':product_name' => $name1));
不妨试试
$db->beginTransaction();
try {
$stmp = $db->prepare("UPDATE jeslot_customer SET cust_outstinding=:totaloutstanding WHERE cust_name=:custname");
$stmp->execute(array(':totaloutstanding' => $tout,':custname' => $custname));
try {
$stmp = $db->prepare("UPDATE jeslot_products SET opening_stock=:clstock WHERE product_name=:name1");
$stmp->execute(array(':clstock' => $clstock,':name1' => $name1));
try {
$stmt = $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)');
$stmt->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();
}
catch(PDOException $e) {
$db->rollback();
$error[] = $e->getMessage();
}
}
catch(PDOException $e) {
$db->rollback();
$error[] = $e->getMessage();
}
}
catch(PDOException $e) {
$db->rollback();
$error[] = $e->getMessage();
}
相关文章:
- 可以't让我的if语句处理js中的html表单输入
- 如何在ReactJS JSX中执行嵌套的if-else语句
- 自动修复”;语句前缺少分号“;
- 如何在 API 调用后和 if 语句中启用提交按钮
- 是“;x==a||b”;以及“;x==a||x==b”;JavaScript中的等效语句
- 带有多个elseif的Javascript if语句
- 这个条件语句的逻辑有问题
- Sharepoint JScript if语句未执行
- 为什么继续;语句冻结浏览器
- Javascript:If-then语句在函数中不起作用
- SharePoint 2010 Jquery/JSON Rest Multiple OR语句-如何
- for循环中的javascript if语句找不到==
- 当使用extern和目标JavaScript时,我如何强制Haxe编译器使用require语句
- jquery if语句返回return wong语句
- 函数在return语句之前返回空对象
- 在if语句下的html中使用javascript变量
- 将错误与if语句混淆
- 如何知道javascript for语句中的所有结果是否都是错误的
- ES6是否引入了一种机制来生成块范围的函数语句(而不是表达式)
- PHP PDO多重准备语句