private function addTermFilterToSelect($term)
    {
        $select = $this->getSelect();

        if ($this->termsLinked === false) {
            $select->joinLeft(
                ['expansion_table' => $this->getTable(ThesaurusInterface::EXPANSION_TABLE_NAME)],
                new \Zend_Db_Expr("main_table.thesaurus_id = expansion_table.thesaurus_id"),
                [
                    'expansion_terms' => new \Zend_Db_Expr("GROUP_CONCAT( DISTINCT expansion_table.term SEPARATOR ',')"),
                ]
            );

            $select->joinLeft(
                ['reference_table' => $this->getTable(ThesaurusInterface::REFERENCE_TABLE_NAME)],
                new \Zend_Db_Expr(
                    "reference_table.term_id = expansion_table.term_id " .
                    "AND main_table." . ThesaurusInterface::THESAURUS_ID . " = reference_table." . ThesaurusInterface::THESAURUS_ID
                ),
                ['reference_terms' => new \Zend_Db_Expr("GROUP_CONCAT( DISTINCT reference_table.term SEPARATOR ',')")]
            );

            $select->group("main_table." . ThesaurusInterface::THESAURUS_ID);

            $select->where("expansion_table.term LIKE '%{$term}%'", $term)
                ->orWhere("reference_table.term LIKE '%{$term}%'", $term);

            $this->termsLinked = true;
        }

        return $select;
    }
private function addTermFilterToSelect($term)
    {
        $select = $this->getSelect();

        if ($this->termsLinked === false) {
            $select->joinLeft(
                ['expansion_table' => $this->getTable(ThesaurusInterface::EXPANSION_TABLE_NAME)],
                new \Zend_Db_Expr("main_table.thesaurus_id = expansion_table.thesaurus_id"),
                [
                    'expansion_terms' => new \Zend_Db_Expr("GROUP_CONCAT( DISTINCT expansion_table.term SEPARATOR ',')"),
                ]
            );

            $select->joinLeft(
                ['reference_table' => $this->getTable(ThesaurusInterface::REFERENCE_TABLE_NAME)],
                new \Zend_Db_Expr(
                    "reference_table.term_id = expansion_table.term_id " .
                    "AND main_table." . ThesaurusInterface::THESAURUS_ID . " = reference_table." . ThesaurusInterface::THESAURUS_ID
                ),
                ['reference_terms' => new \Zend_Db_Expr("GROUP_CONCAT( DISTINCT reference_table.term SEPARATOR ',')")]
            );

            $select->group("main_table." . ThesaurusInterface::THESAURUS_ID);

            $select->where("expansion_table.term LIKE '%{$term}%'", $term)
                ->orWhere("reference_table.term LIKE '%{$term}%'", $term);

            $this->termsLinked = true;
        }

        return $select;
    }
private function addTermFilterToSelect ( $ term ) { $ select = $ this -> getSelect ( ) ; if ( $ this -> termsLinked === false ) { $ select -> joinLeft ( [ 'expansion_table' => $ this -> getTable ( ThesaurusInterface :: EXPANSION_TABLE_NAME ) ] , new \ Zend_Db_Expr ( "main_table.thesaurus_id = expansion_table.thesaurus_id" ) , [ 'expansion_terms' => new \ Zend_Db_Expr ( "GROUP_CONCAT( DISTINCT expansion_table.term SEPARATOR ',')" ) , ] ) ; $ select -> joinLeft ( [ 'reference_table' => $ this -> getTable ( ThesaurusInterface :: REFERENCE_TABLE_NAME ) ] , new \ Zend_Db_Expr ( "reference_table.term_id = expansion_table.term_id " . "AND main_table." . ThesaurusInterface :: THESAURUS_ID . " = reference_table." . ThesaurusInterface :: THESAURUS_ID ) , [ 'reference_terms' => new \ Zend_Db_Expr ( "GROUP_CONCAT( DISTINCT reference_table.term SEPARATOR ',')" ) ] ) ; $ select -> group ( "main_table." . ThesaurusInterface :: THESAURUS_ID ) ; $ select -> where ( "expansion_table.term LIKE '%{$term}%'" , $ term ) -> orWhere ( "reference_table.term LIKE '%{$term}%'" , $ term ) ; $ this -> termsLinked = true ; } return $ select ; }
Inject terms data on collection

@param string $term Term filter text.

@return $this
Inject terms data on collection