Bug #69569 [Opn->Nab]: cpu usage

From: Date: Mon, 04 May 2015 12:48:17 +0000
Subject: Bug #69569 [Opn->Nab]: cpu usage
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-192477@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69569&edit=1 ID: 69569 Updated by: cmb@php.net Reported by: wowkise at gmail dot com Summary: cpu usage -Status: Open +Status: Not a bug Type: Bug Package: PDO MySQL Operating System: Centos PHP Version: 5.5.24 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. The while loop in the test script causes the query to be repeately executed. Previous Comments: ------------------------------------------------------------------------ [2015-05-04 12:00:28] wowkise at gmail dot com 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. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=69569&edit=1

« previous php.bugs (#192477) next »