开发者

Count Records Returned MySQL Doctrine

开发者 https://www.devze.com 2022-12-28 01:53 出处:网络
How do I check the number of records returned from a search of my MySQL database with a statement like thi开发者_C百科s:

How do I check the number of records returned from a search of my MySQL database with a statement like thi开发者_C百科s:

$searchKey = 'Something to search for'; 
$searchResults = Doctrine::getTable('TableName')->createQuery('t')- 
    >where('columnName LIKE ?','%'.$searchKey.'%')->execute(); 


maybe

$searchResults->rowCount();

from here


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号