Jans Rautenbach Jans Rautenbach - 3 years ago 179
PHP Question

num_rows alternative for webspace without MySQLnd

It seems the company I host my webserver with doesn't have MySQLnd installed (or at least not on my server). This means that in php I can not use

, which means I can not use
. I instead have to use
. Is there an alternative for people in my situation to easily get the number of rows without looping through with

Also, same problem with

Answer Source

There doesn't seem to be an alternative. The best I could do was make a method that loops through the rows and returns the count:

function rowCount($stmt) {
    $count = 0;
    while ($stmt->fetch()){
    $stmt->data_seek(0); //reset the stmt to the first row
    return $count;

Note this does not solve the rows_affected problem.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download