[TYPO3-project-4-3] fe_group SQL-statement, question out of curiosity

Niels Fröhling niels.froehling at adsignum.com
Thu Jun 11 19:50:32 CEST 2009


Hy;

I'd like to know why actually the SQL statement for group-enableFields contains
this condition this way:

getMultipleGroupsWhereClause() :=

AND (pages.fe_group='' OR pages.fe_group IS NULL OR pages.fe_group='0' OR
(pages.fe_group LIKE '%,0,%' OR pages.fe_group LIKE '0,%' OR pages.fe_group LIKE
'%,0' OR pages.fe_group='0') OR (pages.fe_group LIKE '%,-1,%' OR pages.fe_group
LIKE '-1,%' OR pages.fe_group LIKE '%,-1' OR pages.fe_group='-1'))

Is there a deeper reason, like an SQL-compatibility issue? Because this can be a
single condition (per group to check for) with 'FIND_IN_SET' and 'FIELD':

getMultipleGroupsWhereClause() :=

  AND (
       FIELD(pages.fe_group, '', '0', NULL) > 0
    OR FIND_IN_SET('0', pages.fe_group) > 0
    OR FIND_IN_SET('-1', pages.fe_group) > 0
  )

  I don't now if it's turns out faster in reality (the 10% speedup aka 2 
microseconds I measured a surely not very deeply evaluated), but it's much more 
readable. :)

Ciao
   Niels



More information about the TYPO3-project-4-3 mailing list