/**
  * Inserts data from a data migration file in a table
  *
  * @param string $tableName
  * @param string $fields
  */
 public function batchInsert($tableName, $fields)
 {
     $migrationData = self::$_migrationPath . $this->_version . '/' . $tableName . '.dat';
     if (!file_exists($migrationData)) {
         return;
         // nothing to do
     }
     self::$_connection->begin();
     self::$_connection->delete($tableName);
     $batchHandler = fopen($migrationData, 'r');
     while (($line = fgets($batchHandler)) !== false) {
         $values = array_map(function ($value) {
             return '' === $value || null === $value ? null : trim($value, "'");
         }, explode('|', rtrim($line)));
         self::$_connection->insert($tableName, $values, $fields);
         unset($line);
     }
     fclose($batchHandler);
     self::$_connection->commit();
 }