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

François Suter fsu-lists at cobweb.ch
Thu Aug 12 18:50:41 CEST 2010


Hi,

> That's it! I agree that the phpDoc says it's optional but the method
> signature is clear:
>
> function exec_SELECTquery($select_fields, $from_table, $where_clause,
> $groupBy = '', $orderBy = '', $limit = '') {
>
> $where_clause is not optional. And when you use the "array" variant of
> exec_SELECT, all parameters are passed to exec_SELECTquery().
>
> BTW, this is not DBAL-related, but Core-related and all methods in Core
> use the famous "1=1" somewhere in there query unless they have without
> "externally added conditions" a base set of conditions on the table.

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?

Cheers

-- 

Francois Suter
Cobweb Development Sarl - http://www.cobweb.ch


More information about the TYPO3-team-core mailing list