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

Steffen Kamper info at sk-typo3.de
Thu Aug 12 19:05:05 CEST 2010


Hi,

François Suter schrieb:
> 
> That's what I thought :-( but I didn't have time to check. But why 
> setting '1=1' instead of an empty string (''). t3lib_db::SELECTquery() 
> does the following:
> 
> $query = 'SELECT ' . $select_fields . ' FROM ' . $from_table . 
> (strlen($where_clause) > 0 ? ' WHERE ' . $where_clause : '');
> 
> so an empty $where_clause will not add the WHERE keyword to the query. 
> Is there anything preventing this solution, which is much cleaner IMO?
> 

the problem rise up when you compute where clause with enableField 
function which always add ' AND ...' which doesn't work with empty where 
clause.
Normal select should work with empty string though, but not NULL

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.

vg Steffen


More information about the TYPO3-team-core mailing list