title: Import large .sql file with php and zend framework
body: <p>I have to import a (big) <code>.sql</code> file to MySQL with PHP and the Zend framework.</p>
  
  <p>The connection is open, and I have <code>$_sql</code> containing the whole content of the SQL file, but - of course, a simple</p>
  
  <pre><code>$this-&gt;db-&gt;query($_sql);
  </code></pre>
  
  <p>will not work.</p>
  
  <p>What can I do to import this large file?</p>
  
  <p>Update: Yes, it is a mysql-dump with structure-definitions of my mysql-database. And yes, it need to run from within php without using command line.</p>
  
  <p>SOLVED:
  I need a mysqli object to fix that, mysqli->multiQuery is the way to go. Here's what my (unit test) bootstrap look like:</p>
  
  <pre><code>&lt;?php
  
  // Define path to application directory
  defined('APPLICATION_PATH')
      || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
  
  // Define application environment
  defined('APPLICATION_ENV')
      || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'testing'));
  
  // Ensure library/ is on include_path
  set_include_path(implode(PATH_SEPARATOR, array(
      realpath(APPLICATION_PATH . '/../library'),
      get_include_path(),
  )));
  
  require_once 'Zend/Loader/Autoloader.php';
  Zend_Loader_Autoloader::getInstance();
  
  // Create application, bootstrap, and run
  $application = new Zend_Application(
          APPLICATION_ENV,
          APPLICATION_PATH . '/configs/application.ini'
  );
  
  $options = $application-&gt;getOptions();
  
  $_sqlFile = realpath(APPLICATION_PATH.'\\..\\tests\\sql\\');
  $_sqlFile .= '\\myLargeSQL.sql';
  $sql = file_get_contents($_sqlFile);
  $mysqliobject = new mysqli(
          $options['resources']['db']['params']['host'],
          $options['resources']['db']['params']['username'],
          $options['resources']['db']['params']['password'],
          $options['resources']['db']['params']['dbname']
  );
  $mysqliobject-&gt;multi_query($sql);
  
  if ($mysqliobject-&gt;errno &lt;&gt; 0) {
      throw new Exception('Error creating temp database in ('.__FILE__.' on line '.__LINE__.')');
  }
  
  $mysqliobject-&gt;close();
  </code></pre>
  
  <p>Don't worry about the \, this is only temporarly (will fix that soon) and yes, i am on a windows machine. So, maybe somebody can use it.</p>