[TYPO3-dev] Tip: use SQL function COUNT(*)
Dmitry Dulepov [typo3]
dmitry at typo3.org
Fri Jul 18 12:36:22 CEST 2008
Hi!
Ingo Renner wrote:
> Martin Kutschker wrote:
>> Anyway it's better to use this:
>>
>> $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('COUNT(*)', 'tx_table');
>
> $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('COUNT(uid)', 'tx_table');
My preferred:
list($row) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('COUNT(*) AS t', 'tx_table');
$count = $row['t'];
No need top free resource. Less chances to forget freeing.
--
Dmitry Dulepov
TYPO3 Core team
More about TYPO3: http://typo3bloke.net/
Subscribe: http://typo3bloke.net/rss.xml
Latest article: http://typo3bloke.net/post-details/cruelty_to_animals/
More information about the TYPO3-dev
mailing list