Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql multi_query intermittently fails

function cpanel_populate_database($dbname) 
{ 
     // populate database
     $sql = file_get_contents(dirname(__FILE__) . '/PHP-Point-Of-Sale/database/database.sql');
     $mysqli->multi_query($sql);

     $mysqli->close();
 }

The sql file is a direct export from phpMyAdmin and about 95% of the time runs without issue and all the tables are created and data is inserted. (I am creating a database from scratch)

The other 5% only the first table or sometimes the first 4 tables are created, but none of the other tables are created (there are 30 tables).

I have decided to NOT use multi_query because it seems buggy and see if the the bug occurs by using just mysql_query on each line after semi-colon. Has anyone ran into issue's like this?

like image 627
Chris Muench Avatar asked Sep 15 '11 06:09

Chris Muench


1 Answers

Fast and effective

system('mysql -h #username# -u #username# -p #database# < #dump_file#');
like image 149
Nimit Dudani Avatar answered Oct 13 '22 05:10

Nimit Dudani