本准则不起作用。我是php pdo的新手。 此语句仅适用于第一个stmp,然后其他不起作用。
代码:
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();
}
答案 0 :(得分:0)
不应该这句话
$stmp1->execute(array(':clstock' => $clstock,':name1' => $name1));
是
$stmp1->execute(array(':clstock' => $clstock,':product_name' => $name1));
答案 1 :(得分:0)
也许试试
$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();
}