I'm trying to create a function which create a "huge" sql file (10 MB) with lots of INSERT
queries.
Generating the file is done, now I'd like to execute the sql.
In PHP, I would do:
$connexion = new mysqli([...]);
if($connexion->multi_query(file_get_contents($filename)) === TRUE ){
// ok ...
}else{
//error
exit;
}
The SQL is in a variable $content
so I tried:
$connection = $this->get('doctrine.dbal.default_connection');
$test = $connection->executeQuery($content);
//or prepare
$test->execute();
$test->closeCursor();
and no errors are displayed but neither is any data in database and I can't use DQL.
Any ideas?
try
$connection = $this->get('doctrine.dbal.default_connection');
$connection->prepare($content);
$test = $connection->exec();
$test->closeCursor();
also check for errors and typo's in your SQL Syntax