[TYPO3-mvc] How does query->contains work

Philipp philippwrann at gmx.at
Tue Apr 2 22:20:19 CEST 2013


Hey

I though im a smart one and wrote a generic method
protected function addFeaturesConstraints($property, $features, array &$constraints, \TYPO3\CMS\Extbase\Persistence\QueryInterface $query, $mode='hit');

So when matching categories, something weird happens. I get 50% correct results and 50% wrong. I dont know how contains work internally, i have no idea how to debug my queries in extbase, thats pretty annoying. Can it be, that i get  wrong result cause the category record is mapped to a parent and the contains iterates thru the properties until the operand is found?

I just need the possibility of adding such contains constraints.

At the moment it looks like this:
protected function addFeaturesConstraints($property, $features, array &$constraints, \TYPO3\CMS\Extbase\Persistence\QueryInterface $query, $mode='hit') {
		if ((is_array($features) || ($features instanceof \Traversable)) && count($features) > 0 && $mode != '0') {
			$logicalAndOr = array();
			foreach($features as $feature) {
				$feature = (method_exists($feature,'getUid')) ? $feature->getUid() : $feature;
				if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($feature)) {
					array_push($logicalAndOr,$query->contains($property,$feature));
				}
			}
			
			switch($mode) {
				case 'all':
					array_push($constraints,$query->logicalAnd($logicalAndOr));
				break;
				case 'hit': default:
					array_push($constraints,$query->logicalOr($logicalAndOr));
				break;
			}
			
		}
	}




a query->in wont work becuase those properties are assigned via MM Relations
a query->equals neither....

what should i use here?
And yea - i dont use direct statements so far and want to keep it that way.

Possibility 1: The parent is taken as a match
Can i drop the column from the identitymap? I extended the TYPO3 category model, so i would have to drop that property via TS i think, i know how i can map a property on a column but how do i drop it, so it isnt mapped anymore?

Possibility 2: Contains just wont work here and my correct results are pure accident.
If thats the case i would have to make an alternative approach, but what would it be?

I am so damaged allready from all that new extbase stuff the last few weeks, please give me a hint here :)


More information about the TYPO3-project-typo3v4mvc mailing list