i use rowCount() php function to get number of my PDO query. but the issue is that this function Calculate deleted items from database.
i want to get number of exist items in DB without deleted items.
tanks
i use rowCount() php function to get number of my PDO query. but the issue is that this function Calculate deleted items from database.
i want to get number of exist items in DB without deleted items.
tanks
You cannot delete rows and get their remaining number in a single query. Make another query like SELECT COUNT(*) FROM table_name
.
PDOStatement::rowCount
is meant to count the rows affected by DELETE, INSERT, or UPDATE queries.
If you want to get the number of rows returned by a SELECT query, then you can do it with a SELECT COUNT(*)
statement. No need to use rowCount
at all.
From the documentation:
For most databases, PDOStatement::rowCount() does not return the number of rows affected by a SELECT statement.