[TYPO3-core] FYI #15396: Wrong query - crashes with DBAL

Jigal van Hemert jigal at xs4all.nl
Fri Aug 13 09:45:51 CEST 2010


Hi,

On 12-8-2010 20:58, François Suter wrote:
>> the problem rise up when you compute where clause with enableField
>> function which always add ' AND ...' which doesn't work with empty where
>> clause.
> I know, but in this case there's no enableField clause added afterwards.

It's easy to forget in most situation where query parts are built as the 
result of various tests and later on when calling the db methods 
enableFields, etc. are added.

In many cases developing a safe style is better than writing it on a 
case by case basis. (Maybe not for you :-) )

>> Anyway adding "1=1" as dummy doesn't harm imho, having where present is
>> cleaner than omitting it, especially when you modify at later point.
>
> I disagree. I think having all these '1=1' lying around is really lousy
> programming style.

Having WHERE 1=1 in a query may look "lousy", but every query is parsed 
by the DBMS, an optimizer looks at every part and eventually an 
execution path is constructed. Optimizing this where-clause away is a 
trivial operation and will not add significantly to the total execution 
time.
Just an opinion...

-- 
Jigal van Hemert
skype:jigal.van.hemert
msn: jigal at xs4all.nl
http://twitter.com/jigalvh


More information about the TYPO3-team-core mailing list