[TYPO3-mvc] How does query->contains work
Till Wimmer
g4-lisz at tonarchiv.ch
Wed Apr 3 19:34:21 CEST 2013
Hi Philipp,
similar issue here: http://stackoverflow.com/questions/15774323
Couldn't find a solution yet - I think i have to write a SQL-statement of my own (one JOIN per AND condition) :(
Cheers,
Till
On 04/02/2013 10:20 PM, Philipp wrote:
> 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 :)
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
More information about the TYPO3-project-typo3v4mvc
mailing list