[TYPO3-german] Re: Re: MM relation mehrere AND Bedingungen aneinanderhängen

Dominic Garms djgarms at gmail.com
Thu Apr 21 09:30:14 CEST 2011


> SELECT tt_news.* FROM tt_news,
> tt_news_cat_mm as a,
> tt_news_cat_mm as b
> WHERE a.uid_local = uid
> AND b.uid_local = uid
> AND a.uid_foreign = 2
> AND b.uid_foreign = 5

Hallo Bernd,

tausend Dank für deine Antwort, hier mal die Lösung die aber nochmal 
genauer getestet werden muss (für drei POST Variablen):

$additionalFrom = $additionalWhere = '';
if(t3lib_div::_POST('val1')) {
   $additionalFrom .= ',tt_news_cat_mm as a';
   $additionalWhere .= ' AND a.uid_local=uid AND 
a.uid_foreign='.t3lib_div::_POST('val1');
}
if(t3lib_div::_POST('val2')) {
   $additionalFrom .= ',tt_news_cat_mm as b';
   $additionalWhere .= ' AND b.uid_local=uid AND 
b.uid_foreign='.t3lib_div::_POST('val2');
}
if(t3lib_div::_POST('val3')) {
   $additionalFrom .= ',tt_news_cat_mm as c';
   $additionalWhere .= ' AND c.uid_local=uid AND 
c.uid_foreign='.t3lib_div::_POST('val3');
}
										
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( 	
   'uid,title',
   'tt_news'.$additionalFrom,
   '1'.$additionalWhere,
   $groupBy = 'uid',
   $orderBy = '',
   $limit = ''
);

Wäre eigentlich praktisch wenn es eine Core TYPO3_DB Funktion dafür 
gäbe. Oder geht es euch nicht so, dass ihr bei Suchen über MM-Relationen 
auf dieses Problem stößt?

Viele Grüße

Dominic


More information about the TYPO3-german mailing list