This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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); |