|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69569 cpu usage
Submitted: 2015-05-04 12:00 UTC Modified: 2015-05-04 12:48 UTC
From: wowkise at gmail dot com Assigned: cmb (profile)
Status: Not a bug Package: PDO MySQL
PHP Version: 5.5.24 OS: Centos
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: wowkise at gmail dot com
New email:
PHP Version: OS:


 [2015-05-04 12:00 UTC] wowkise at gmail dot com
infinite results and huge CPU usage

Test script:

$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);
        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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-05-04 12:48 UTC]
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2015-05-04 12:48 UTC]
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 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.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 07:01:29 2024 UTC