[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 22:01:03 CET 2010


Ernesto Baschny [cron IT] schrieb am 16.11.2010 21:44:
> 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.

* Heated discussion in the background *

I would love to hear others opinions on that, if pro or contra throwing
exceptions on new methods of t3lib_db.

Cheers,
Ernesto



More information about the TYPO3-team-core mailing list