I know this question has been asked before but it seems like the solutions have been specific to the problem presented.
I have a codebase with hundreds of instances where mssql_num_rows is 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(*) FROM table
queries as I have too many specific select statements. - I could run a
preg_replace
to remove everything betweenSELECT and FROM
and then replace with aCOUNT(*)
and run a second query but this assumes all queries are setup a certain way. - I could
fetchAll
first thencount()
the results but that means upgrading all instances of the if statements.
So what is the best all around replacement to a *_num_rows function if people are updating their code to PDO. Not something that solves a specific problem, but something that replaces the functionality of *_num_rows. If that's not possible what allowed it to be possible before?