[TYPO3-dev] Tip: use SQL function COUNT(*)
Martin Kutschker
masi-no at spam-typo3.org
Fri Jul 18 12:54:38 CEST 2008
Dmitry Dulepov [typo3] schrieb:
> 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.
Very good.
Masi
More information about the TYPO3-dev
mailing list