kla/php-activerecord — pull request #225 by fayland (2012-08-09 09:18:41+00:00)
Title: support custom COUNT like COUNT(DISTINCT col)

when we need some SQL like

SELECT COUNT(DISTINCT UsersUrls.`Index`) FROM `UsersUrls` JOIN UsersUrlsCategories ON UsersUrlsCategories.UrlIndex = UsersUrls.Index JOIN UrlsSearchTerms ON UrlsSearchTerms.UrlIndex = UsersUrls.Index JOIN SearchTerms ON SearchTerms.`Index`=UrlsSearchTerms.SearchTermIndex WHERE UsersUrls.UserIndex = ? AND UsersUrlsCategories.CategoryIndex IN (?) AND SearchTerms.SearchEngineIndex IN (?)

the patch would be helpful that we can set

$searchcnd['select'] = 'COUNT(DISTINCT UsersUrls.`Index`)';
$total = UsersUrls::count($searchcnd);

we can't approach our SQL with COUNT(*).

Thanks.