title: Best practice: Import mySQL file in PHP; split queries
body: <p>I have a situation where I have to update a web site on a shared hosting provider. The site has a CMS. Uploading the CMS's files is pretty straightforward using FTP.</p>
  
  <p>I also have to import a big (relative to the confines of a PHP script) database file (Around 2-3 MB uncompressed). Mysql is closed for access from the outside, so I have to upload a file using FTP, and start a PHP script to import it. Sadly, I do not have access to the <code>mysql</code> command line function so I have to parse and query it using native PHP. I also can't use LOAD DATA INFILE. I also can't use any kind of interactive front-end like phpMyAdmin, it needs to run in an automated fashion. I also can't use <code>mysqli_multi_query()</code>.</p>
  
  <p>Does anybody know or have a already coded, simple solution that <strong>reliably</strong> splits such a file into single queries (there could be multi-line statements) and runs the query. I would like to avoid to start fiddling with it myself due to the many gotchas that I'm  likely to come across (How to detect whether a field delimiter is part of the data; how to deal with line breaks in memo fields; and so on). There <em>must</em> be a ready made solution for this.</p>