[TYPO3-mvc] Last question today: MM query

Michel Tremblay michel.tremblay at infoglobe.ca
Tue Jun 2 05:50:53 CEST 2009


I was just about to ask the same question. There should be a function to 
do this in the dataMapper. I think the function would be very similar to 
dataMapper->fetchWithRelationTable.

This could even be used in blog_example to find posts by tag.

Susanne Moog a écrit :
> Hello again :-)
> 
> I promise this really is the last question for today. I have written the
> following function to get my MM query working and wanted to know if
> there already is an extbase/fluid wrapper for such a query:
> 
> public function findWithGroups($groups, $limit=NULL, $sortBy='last_name') {
> 
> 	$select = 'tx_addresses_domain_model_address.uid';
> 	$local_table = 'tx_addresses_domain_model_address';
> 	$mm_table = 'tx_addresses_address_addressgroup_mm';
> 	$foreign_table = 'tx_addresses_domain_model_addressgroup';
> 	$whereClause = 'AND tx_addresses_domain_model_addressgroup.uid IN (' .
> $groups . ')';
> 		
> 	$res =
> $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query($select,$local_table,$mm_table,$foreign_table,$whereClause,'',$sortBy,$limit);
> 
> 		
> 	$rows = Array();
> 	while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
> 		$rows[] = $row['uid'];	
> 	}
> 	$foundAddressesList = implode(',', $rows);
> 	return $this->findWhere('uid IN (' . $foundAddressesList . ')', '',
> $sortBy);
> }
> 
> 
> Thanks!
> 
> Susanne
> 


More information about the TYPO3-project-typo3v4mvc mailing list