Jump to content


multiple select filter doesnt work


  • Please log in to reply
1 reply to this topic

#1 crocerylover

crocerylover

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 13 April 2019 - 03:09 PM

hello friends 

 

i bought the crocery crud entreprise , i have a case when i did a n to n relation on 3 tables .

when im trying to filter the list based on the field that gives multiples values it doesnt work .

it has to be some sort of bug , its the same bug even on the online demo 

 

can everybody solve this prob plz 



#2 crocerylover

crocerylover

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 08 May 2019 - 01:43 AM

the prob is in this line

 

 

    public function whereStatements($select)
    {
        if ($this->_filters) {
            foreach ($this->_filters as $filterName => $filter) {
                if ($this->isFieldWithRelationNtoN($filterName)) {
                    $rel = $this->_relation_n_n[$filterName];
 
                    $select->join($rel->junctionTable,
                        $rel->junctionTable . '.' . $rel->primaryKeyJunctionToCurrent . '=' .
                        $this->tableName . '.' . $this->getPrimaryKeyField($this->tableName). '',
                        []
                    );
 
                    if (is_array($filter)) {
                        $predictateSetArray = [];
                        foreach ($filter as $primaryKeyId) {
                            $predictateSetArray[] = new Predicate\Operator(
                                $rel->junctionTable . '.' . $rel->primaryKeyToReferrerTable, '=' , $primaryKeyId
                            );
                        }
 
                        if (!empty($predictateSetArray)) {
                            $select->where(new Predicate\PredicateSet($predictateSetArray, PredicateSet::OP_OR));
                        }
                    } else {
                        $select->where([
                            $rel->junctionTable . '.' . $rel->primaryKeyToReferrerTable => $filter
                        ]);
                    }
 
                }
            }
 
            // @todo: Remove duplicate code with the above filters
        } else if ($this->_filters_or) {
            foreach ($this->_filters_or as $filterName => $filter) {
                if ($this->isFieldWithRelationNtoN($filterName)) {
                    $rel = $this->_relation_n_n[$filterName];
 
                    $select->join($rel->junctionTable,
                        $rel->junctionTable . '.' . $rel->primaryKeyJunctionToCurrent . '=' .
                        $this->tableName . '.' . $this->getPrimaryKeyField($this->tableName). '',
                        []
                    );
 
                    if (is_array($filter)) {
                        $predictateSetArray = [];
                        foreach ($filter as $primaryKeyId) {
                            $predictateSetArray[] = new Predicate\Operator(
                                $rel->junctionTable . '.' . $rel->primaryKeyToReferrerTable, '=' , $primaryKeyId
                            );
                        }
 
                        if (!empty($predictateSetArray)) {
                            $select->where(new Predicate\PredicateSet($predictateSetArray, PredicateSet::OP_OR));
                        }
                    } else {
                        $select->where([
                            $rel->junctionTable . '.' . $rel->primaryKeyToReferrerTable => $filter
                        ]);
                    }
 
                }
            }
        }

 

on the first if , we can see clear that the operator is OP_OR . it should be and operator .and even ,the prob is still because the query is wrong . plz  i need a fix to this . ty for your help






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users