1
count rows pdo
CGuild1.com > Tips & Tricks > count rows pdo

Get a count of rows with PDO - PHP

Here is how to count the total rows with a pdo connection and mysql.

$nRows = $pdo->query("select count(*) from blah")->fetchColumn();
echo $nRows;


I have also found this way to be a little easier, specifically on a radius search.

$rowCount = $db->query('SELECT * FROM table')->rowCount();
echo $row_count.' rows selected';


Original source on Stackoverflow
©2024 CGuild1.com