[TYPO3-core] RFC #11916: Feature: New TYPO3_DB method for queries that expect just a single result row

Ernesto Baschny [cron IT] ernst at cron-it.de
Tue Nov 16 21:44:20 CET 2010


Steffen Kamper schrieb am 16.11.2010 21:16:
> Hi,
> 
> +1 by reading and testing.
> 
> Made little adjsutment:
> 
> * last parameter renamed to $fetchRowMethod
> * return NULL when error
> 
> I will commit later if noone shouts loud :)

I still prefer to have an exception thrown:

This is not about "debugging", but about a production site. If an error
occurs, the return value is "NULL", which is not what is documented in
the header (@return array). The calling party will have to handle this,
and usually it is an unneeded overhead. Especially if you cannot
differenciate if NULL is just because there were no records or if the
SQL was buggy. Very annoying!!!

Throwing an error will allow "anyone" to catch, and at the end display
the standard TYPO3 error page (also allowing to log the error etc).

So I suggest to throw an exception on new methods, which is the modern
way of dealing with an error and then making sure the returned value is
*always* an array (initialize $output with array()).

See suggestion in v6.

Cheers,
Ernesto

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 11916_v6.diff
URL: <http://lists.typo3.org/pipermail/typo3-team-core/attachments/20101116/842853d3/attachment-0001.asc>


More information about the TYPO3-team-core mailing list