I have a symfony command that exports more than 100,000 lines from a database to an xml file.
In the current version of the php script everything is first put in RAM and then sent to a twig file which writes it to RAM (with the ob functions) and then everything is written to disk.
Here is the sample code snippet:
$results = $dbSession->query(/*SQL query*/);
$data = [];
foreach ($results as $row) {
$data[] = $row;
}
file_put_contents(
$xmlFilename,
$twig->render($twigFileName,
$data
)
);
How can I stream directly from the database to the output file?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…