[TYPO3-core] RFC: minor optimisation of getRecordRaw()

Dmitry Dulepov dmitry at typo3.org
Fri Dec 1 09:02:33 CET 2006


Martin Kutschker wrote:
> I noticed that t3lib_BEfunc::getRecordRaw() does not free the SQL 
> result. While changing that I have also added a LIMIT to the query as 
> only the first found record is used.

Good idea but I see a possibility for PHP errors here:

> +		$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, $table, $where, '', '', '1');
> +		$row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);

Second line will produce PHP error if first line does not return proper 
result set. Of course, it will not happen under normal conditions but 
still it would be cleaner to check for result:

$row = null;
if (false !== ($res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
		$fields, $table, $where, '', '', '1'))) {
	$row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
return $row;

This would also take care about Franz's comment. $row on the first line 
can also be set to false, which will not be 100% identical to previous 
behavior but will look nicer and will be fully compatible with existing 

Dmitry Dulepov

Web: http://typo3bloke.net/
Skype: callto:liels_bugs

"It is our choices, that show what we truly are,
far more than our abilities." (A.P.W.B.D.)

More information about the TYPO3-team-core mailing list