How to insert multiple rows efficiently in mysql using php

I trying to perform bulk-insert in php using mysql database, I found similar post on SO and I did slight changes as per my need

 //db interaction   ....  ....   $ord_id= mysqli_insert_id($conn);  $stmt = $conn->prepare("INSERT INTO ORDERS(product_id, tot_qty,tot_act_amt,tot_discount_amt,ord_id)"                     . " VALUES(?,?,?,?,?)");             $dbcon->query("START TRANSACTION");             foreach ($product as $item) {                 $prod_id = $item['id'];                 $tot_qty = $item['quantity'];                  $product_actual_total = $item['price'] * $tot_qty;                 $total_product_discount = $product_actual_total - ($item['discount'] * $tot_qty);                  $stmt->bind_param("iiddi", $prod_id, $tot_qty, $product_actual_total, $total_product_discount, $ord_id);  //failing here                 $stmt->execute();             }             $stmt->close();             $dbcon->query("COMMIT"); 

When I'm trying to execute above code, I'm getting following error :

Fatal error: Uncaught Error: Call to a member function bind_param() on boolean in userDA.php:176 Stack trace: #0 {main} thrown in userDA.php on line 176 

Am I missing anything ?


Category: php Time: 2016-07-30 Views: 0

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C), All Rights Reserved.

processed in 0.116 (s). 12 q(s)