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