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 betweenselect , from
, replacecount(*)
, run second query assumes queries setup way. - i
fetchall
firstcount()
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
Post a Comment