|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-05-04 12:48 UTC] cmb@php.net
-Status: Open
+Status: Not a bug
-Assigned To:
+Assigned To: cmb
[2015-05-04 12:48 UTC] cmb@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 00:00:01 2025 UTC |
Description: ------------ infinite results and huge CPU usage Test script: --------------- <?php $pdo = new \PDO('mysql:host=localhost;dbname=test', 'test', 'test'); $db = new db( $pdo ); class db { public function __construct(\PDO &$pdo = null, array $options = []) { $this->pdo = $pdo; } public function query( $sql, array $bind = [], array $options = []) { $stmt = $this->pdo->prepare($sql); $stmt->execute($bind); return $stmt; } } $sql = "SELECT change_id as id FROM ac_changelog LIMIT 10"; while( $row = $db->query( $sql )->fetch() ) { echo $row['id'] . PHP_EOL; } ?> Expected result: ---------------- 10 results returned. Actual result: -------------- infinite results and huge CPU usage and until the process is killed. changing code to $stmt = $db->query( $sql ); while( $row = $stmt->fetch() ) { echo $row['id'] . PHP_EOL; } fixes the problem.