title: PDO large insert statement
body: <p>I have a large textfile with rows of data that need to be imported in the database. But the file contains like 300000 rows and I can't get it to work, because the query seems too big.</p>
  
  <pre><code>$all_inserts    = array();
  $count          = 0;
  foreach($file as $line) {
      if($count &gt; 0) {
          $modelnummer    = trim(substr($line, 0, 4));
          $datum          = trim(substr($line, 4, 8));
          $acc_nummer     = trim(substr($line, 12, 4));
          $acc_volgnr     = trim(substr($line, 16, 1));
          $prijs          = trim(substr($line, 17,5));
          $mutatiecode    = trim(substr($line, 22,1));
          $all_inserts[] = array($modelnummer, $datum, $acc_nummer, $acc_volgnr, $prijs, $this-&gt;quote($mutatiecode));
      }
      $count++;
  }
  $query = 'INSERT INTO accessoire_model_brommer (modelnummer, datum, acc_nummer, acc_volgnr, prijs, mutatiecode) VALUES ';
  $rows  = array();
  foreach($all_inserts as $one_insert) {
      $rows[] = '(' . implode(',', $one_insert) . ')';
  }
  $query .= ' ' . implode(',', $rows);
  $db-&gt;query($query);
  </code></pre>
  
  <p>I used above code for smaller files and it works fine and fast. But it doesn't work for the bigger files. Does someone know a better way to read and insert this file?</p>
  
  <p>Also tried to use an insert statement per row within a transaction, but it doesn't work either.</p>