Posted By

saturngod on 04/11/10


Tagged

mysql insert batch


Versions (?)

mysql batch insert


 / Published in: PHP
 

URL: http://www.hiteshagrawal.com/mysql/mysql-batch-insert-using-php

  1. < ?
  2. $batchconnection = new mysqli($dbHost, $dbUser, $dbPass, $dbName);
  3. if ($batchconnection->connect_error) {
  4. echo "Error Occurred While Connection To DataBase";
  5. }
  6. $sqlStatements = "insert into test(name) values('Hitesh');insert into test(name) values('Agrawal');insert into test(name) values('Hello');insert into test(name) values('World')";
  7.  
  8. $sqlResult = $batchconnection->multi_query($sqlStatements);
  9.  
  10. if($sqlResult == true) {
  11. echo "Successfully Inserted Records";
  12. } else {
  13. echo "Some Error Occured While Inserting Records";
  14. }
  15. ?>

Report this snippet  

You need to login to post a comment.