Skip to content

Instantly share code, notes, and snippets.

@paulfcdd
paulfcdd / gist:b7dbe0286e0ca97853796c391377a1d8
Created October 15, 2025 11:58
Pavlo Novykov Test task
# Q1
THe error is occur because of fetchAll load all result into the memory, so in case of big tables it can finish with error memory.
To prevent it we need to read results line by line using fetch, do not use SELECT * and select columns we need instead. Example of the
code which fix this issue
```
<?php
$sql = 'SELECT id, col1, col2
FROM largeTable
ORDER BY id';
$stmt = $pdo->query($sql, PDO::FETCH_ASSOC);