问题
How do I check the number of records returned from a search of my MySQL database with a statement like this:
$searchKey = 'Something to search for';
$searchResults = Doctrine::getTable('TableName')->createQuery('t')-
>where('columnName LIKE ?','%'.$searchKey.'%')->execute();
回答1:
maybe
$searchResults->rowCount();
from here
回答2:
Wouldn't
Doctrine::getTable('TableName')->createQuery('t')
->where('columnName LIKE ?','%'.$searchKey.'%')
->execute()
->rowCount();
fetch the results from the database?
In that case,
Doctrine::getTable('TableName')->createQuery('t')
->where('columnName LIKE ?','%'.$searchKey.'%')
->count()
be a better solution?
来源:https://stackoverflow.com/questions/2718410/count-records-returned-mysql-doctrine