[TYPO3-core] Checking return values of SQL query - see bug#3794
Martin Kutschker
Martin.Kutschker at n0spam-blackbox.net
Fri Oct 13 14:23:09 CEST 2006
Hi!
Bug http://bugs.typo3.org/view.php?id=3794 complains about a PHP warning in
t3lib\class.t3lib_page.php:getHash().
It's a classic SELECT and fetch but don't check result. Is it worth the
hassle to check if the result is a valid handle (ie not FALSE)?
Code woud look like this (plus a new check for a cache miss (returns FALSE).
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('content', 'cache_hash',
'hash='.$GLOBALS['TYPO3_DB']->fullQuoteStr($hash, 'cache_hash').
$whereAdd
);
if ($res!==FALSE && $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$GLOBALS['TYPO3_DB']->sql_free_result($res);
return is_array($row) ? $row['content'] : FALSE;
}
The FALSE on miss is a new idea (not in the bug report), but it might be
nice to distinct between miss and an empty string as content in the cache.
Masi
More information about the TYPO3-team-core
mailing list