PHP Classes

rowcount() returning zero when records exist

Recommend this page to a friend!

      PDO Multi Connection Class  >  All threads  >  rowcount() returning zero when...  >  (Un) Subscribe thread alerts  
Subject:rowcount() returning zero when...
Summary:rowcount() / stmntCount adding too many spaces into query
Messages:1
Author:warren porren
Date:2013-09-01 18:51:55
 

  1. rowcount() returning zero when...   Reply   Report abuse  
Picture of warren porren warren porren - 2013-09-01 18:51:55
Great class, but had one small issue.
Have been trying it out and noticed today that I kept getting a value of zero when I performed rowcount() after a query.
After checking the mysql log I found that the stmntCount() was putting double spaces into the query.
i.e. "SELECT count(*) FROM tbl WHERE cat_name='spare parts'"
so there is no category called "spare (double space) parts".

pdo_database.class.php
...
private function stmntCount($sql_statement)
...

$query_final .= " " . trim($query_split[$x]) . " ";

Got it working by making it...
$query_final .= trim($query_split[$x]) . " ";

But haven't done enough testing to see if that breaks with a different query.