I've got an array of strings which are sql "input into ..." queries. Im looping through this array combining each 50 of them into a new string and then sending to mysql database. After that I reset my temporary string and prepare it for new queries.
But my array stops after first query and doesn't want to send everything so on DB server I've always got only 50 records. How can I fix my code and send everything?
code:
$data // array with sql queries
$queryPartial = ''; // additional string for 50 queries to send
foreach ($data as $index => $queryToSend) {
$queryPartial .= $queryToSend;
// send partials query
if($index % 50 == 0)
{
if($connection->multi_query($queryPartial))
{
$this->output->writeln('succesfull query number: '.$index);
}
$queryPartial = ''; // clean string for next queries
}
}
//send the rest of the remaining queries
if($queryPartial !== ''){
if($connection->multi_query($queryPartial))
{
$this->output->writeln('rest of the queries sended');
}
}
$connection->close();