Count Records returned MySQL Doctrine

How to check the number of records returned when searching for my MySQL database with a statement:

$searchKey = 'Something to search for'; $searchResults = Doctrine::getTable('TableName')->createQuery('t')- >where('columnName LIKE ?','%'.$searchKey.'%')->execute(); 
+4
php mysql doctrine
source share
2 answers

may be

 $searchResults->rowCount(); 

from here

+7
source share

Would not be

Doctrine::getTable('TableName')->createQuery('t')
->where('columnName LIKE ?','%'.$searchKey.'%') ->execute() ->rowCount();

retrieve results from a database?

In this case

Doctrine::getTable('TableName')->createQuery('t')
->where('columnName LIKE ?','%'.$searchKey.'%') ->count()

- the best solution?

+6
source share

All Articles