According to the manual, there is a PDOStatement->rowCount
method ; but it shouldn’t be used (quoting) :
For most databases,
PDOStatement::rowCount()
does not
return the number of rows affected by
aSELECT
statement.
Instead, use
PDO::query()
to issue aSELECT COUNT(*)
statement with the same
predicates as your intendedSELECT
statement, then use
PDOStatement::fetchColumn()
to
retrieve the number of rows that will
be returned.
Your application can then
perform the correct action.
If you already have a recordset, and want to know how many lines are in it, you’ll have to fetch the data, using one of the fetch*
methods ; and use count — like you suggested.