header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Content-Type: {$file->getMimetype()}");
header("Content-Disposition: inline; filename=".$filename.";");
header("Content-Length: ".strlen($file_content));
echo $file_content;
$filename = 'text.txt';
$total = 0;
$buffer = [];
$h = fopen($filename, 'r');
while (! feof($h)) {
if ($total > 100) {
// var_export($buffer); // Вывести или выполнить обработку каждых 100 строк
$total = 0;
$buffer = [];
}
$buffer[] = fgets($h);
$total++;
}
fclose($h);
if (! empty($buffer)) {
// var_export($buffer); // Вывести или выполнить обработку оставшихся строк
}
select c.title, count(p.product_id )
from (
select title, category_id from categories c where c.category_id IN (1,2)
UNION
select
(select title from categories c1 where c1.category_id = c.parent_id) as title,
category_id
from categories c where parent_id IN (1,2)
) c
JOIN products p ON p.category_id = c.category_id
GROUP BY c.title