 |
|
Case ของผมคือ
กำลังทำ shopping cart อยู่แล้วแบบว่า จะต้อง insert 1 order กับ n order detail เพื่อเอาไว้อิงกัน
เลย Loop แล้วเพิ่มเข้า $sql แล้วตอนสุดท้ายก็ไปยิงเข้า MySQL ทีเดียว ทั้ง insert 1 order กับ n order detail เลยอ่ะคับ
ค่าใน $sql พอผม echo ออกมาแล้ว copy ไปรันตรงเลยใน phpMyAdmin มันจะทำงานได้ปกติไม่ error
ผมใช้ function mysql_qeury() >>
$sql = "insert into zodic_order(order_id, customer_id, order_date, order_place, pay_by_id, order_status_id) values(3, 2, '2007-08-03 18 24', 'asdadasdaddfg dfasd as ', 1, 1); nsert into zodic_order_detail(order_id, product_id, unit) values(3, 7, 10); insert into zodic_order_detail(order_id, product_id, unit) values(3, 9, 5);";
mysql_qeury($sql);
มัน return error ว่า >>
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '; insert into zodic_order_detail(order_id, product_id, unit) values(3, 7, 10); i' at line 1
แต่ว่าพอผมเอา String ใน $sql ไป สั่งใน phpMyAdmin แล้วมันทำงานได้
เลยอยากรู้ว่ามีวิธีให้ส่ง Query ทีละหลายๆคำสั่งไปทำได้หรือป่าว เพราะถ้าต้องวน Loop ถ้าระหว่างวนเกิดปัญหา ข้อมูลก็จะเข้า DB ไปไม่ครบ ถ้าส่งในทีเดียวน่าจะเกิดปัญหาได้น้อยกว่า
Tag : - - - -
|
|
 |
 |
 |
 |
Date :
3 ส.ค. 2550 19:37:57 |
By :
ashutei |
View :
1608 |
Reply :
0 |
|
 |
 |
 |
 |
|
|
|
 |