[TYPO3-core] RFC #14818: Performance: Use mysql find_in_set-function in t3lib_db->listQuery()

Xavier Perseguers typo3 at perseguers.ch
Fri Jul 16 13:29:34 CEST 2010


Hi,

> Is it possible that the functions get's changed to :
>
> $where = 'find_in_set(\'' . $pattern . '\',' . $field . ') != 0';
>
> The rationale behind this is that it's easer to port
> this function to other databases because for example
> PostgreSQL 'wants' a boolean evaluation, and mysql
> fakes integer for boolean, a bit like what PHP does (incorect IMHO).
> It's also to show other people reading the code the correct way to do it.
>
> However, I leave the final decision up to you and Xavier (or others).

Well, after digging into that again after T3DD10, and although I agree 
that MySQL behaves a bit oddly by faking integer for boolean, I don't 
want to add != 0 after this find_in_set. Rational is that I "natively" 
handle FIND_IN_SET in DBAL, meaning this listQuery() method does not 
have to be overriden at all but I add the != 0 or == 1 according to the 
underlying DBMS.

Problem is that when I create the query for Oracle, I enhanced it like 
that to prevent all those nastly LIKE statements:

SELECT * FROM "fe_users" WHERE ','||"usergroup"||',' LIKE '%,10,%'

but having != 0 in the MySQL query adds this non-sense clause after the 
LIKE which makes the query fail.

I still have to test the MSSQL version of FIND_IN_SET and will then 
commit both RFC #14818 and #14985 unless I find something left to be 
made even better.

Xavier


More information about the TYPO3-team-core mailing list