php - PDO equivalent of mysql_num_rows or mssql_num_rows -


i know question has been asked before seems solutions have been specific problem presented.

i have codebase hundreds of instances mssql_num_rows used.

code example:

$db->execute($sql);  if ($db->getrowsaffected() > 0) {     $total = $db->fetch(); 

in db class:

$this->rowsaffected = mssql_num_rows($this->query_result); 
  • i can't create generic select count(*) table queries have many specific select statements.
  • i run preg_replace remove between select , from , replace count(*) , run second query assumes queries setup way.
  • i fetchall first count() results means upgrading instances of if statements.

so best around replacement *_num_rows function if people updating code pdo. not solves specific problem, replaces functionality of *_num_rows. if that's not possible allowed possible before?

if want count rows can pdo:

$sql = 'select * users'; $data = $conn->query($sql); $rows = $data->fetchall(); $num_rows = count($rows); 

there no way directly count rows when using select statement pdo.


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -