How would I go about getting the total number of rows in a table using the PDO library?
Below is how I execute my queries.
$query = "
";
try
{
$stmt = $db->prepare($query);
$stmt->execute();
}
catch(PDOException $ex)
{
die("Failed to run query: " . $ex->getMessage());
}
EDIT
I should have made it more clear, I'm sorry, but I was looking for the PDO way of getting number of rows...
A database does not have rows. A table, however, does. What I think that you are looking for, is a SQL query that will count the rows in a table. Which you can do like this:
SELECT COUNT(*) AS count FROM table
If you execute that query, the count field in the result will contain the number of rows in the table.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.