src/Attribute/TranslatedSelect.php
public function sortIds($idList, $strDirection)
    {
        $metaModel    = $this->getMetaModel();
        $strTableName = $this->getSortingOverrideTable();
        if ($strTableName) {
            $strColNameId  = 'id';
            $strSortColumn = $this->getSortingOverrideColumn();

            return $this->connection->createQueryBuilder()
                ->select('m.id')
                ->from($metaModel->getTableName(), 'm')
                ->leftJoin('m', $strTableName, 't', sprintf('t.%s=m.%s', $strColNameId, $this->getColName()))
                ->orderBy('t.' . $strSortColumn, $strDirection)
                ->execute()
                ->fetchAll(\PDO::FETCH_COLUMN, 0);
        }

        $addWhere = $this->getAdditionalWhere();
        $langSet  = sprintf('\'%s\',\'%s\'', $metaModel->getActiveLanguage(), $metaModel->getFallbackLanguage());

        $subSelect = $this->connection->createQueryBuilder()
            ->select('z.id')
            ->from($this->getSelectSource(), 'z')
            ->where($this->getLanguageColumn() . 'IN(:langset)')
            ->andWhere('z.' . $this->getIdColumn() . '=m.' . $this->getColName())
            ->orderBy(sprintf('FIELD(z.%s,%s)', $this->getLanguageColumn(), $langSet))
            ->setMaxResults(1);

        if ($addWhere) {
            $subSelect->andWhere($addWhere);
        }

        $sorted = $this->connection->createQueryBuilder()
            ->select('m.id')
            ->from($this->getMetaModel()->getTableName(), 'm')
            ->leftJoin('m', $this->getSelectSource(), 's', sprintf('s.id = (%s)', $subSelect->getSQL()))
            ->where('m.id IN(:ids)')
            ->orderBy('s.' . $this->getSortingColumn(), $strDirection)
            ->setParameter('ids', $idList)
            ->setParameter('langset', $langSet)
            ->execute()->fetchAll(\PDO::FETCH_COLUMN, 0);

        return $sorted;
    }
public function sortIds($idList, $strDirection)
    {
        $metaModel    = $this->getMetaModel();
        $strTableName = $this->getSortingOverrideTable();
        if ($strTableName) {
            $strColNameId  = 'id';
            $strSortColumn = $this->getSortingOverrideColumn();

            return $this->connection->createQueryBuilder()
                ->select('m.id')
                ->from($metaModel->getTableName(), 'm')
                ->leftJoin('m', $strTableName, 't', sprintf('t.%s=m.%s', $strColNameId, $this->getColName()))
                ->orderBy('t.' . $strSortColumn, $strDirection)
                ->execute()
                ->fetchAll(\PDO::FETCH_COLUMN, 0);
        }

        $addWhere = $this->getAdditionalWhere();
        $langSet  = sprintf('\'%s\',\'%s\'', $metaModel->getActiveLanguage(), $metaModel->getFallbackLanguage());

        $subSelect = $this->connection->createQueryBuilder()
            ->select('z.id')
            ->from($this->getSelectSource(), 'z')
            ->where($this->getLanguageColumn() . 'IN(:langset)')
            ->andWhere('z.' . $this->getIdColumn() . '=m.' . $this->getColName())
            ->orderBy(sprintf('FIELD(z.%s,%s)', $this->getLanguageColumn(), $langSet))
            ->setMaxResults(1);

        if ($addWhere) {
            $subSelect->andWhere($addWhere);
        }

        $sorted = $this->connection->createQueryBuilder()
            ->select('m.id')
            ->from($this->getMetaModel()->getTableName(), 'm')
            ->leftJoin('m', $this->getSelectSource(), 's', sprintf('s.id = (%s)', $subSelect->getSQL()))
            ->where('m.id IN(:ids)')
            ->orderBy('s.' . $this->getSortingColumn(), $strDirection)
            ->setParameter('ids', $idList)
            ->setParameter('langset', $langSet)
            ->execute()->fetchAll(\PDO::FETCH_COLUMN, 0);

        return $sorted;
    }
public function sortIds ( $ idList , $ strDirection ) { $ metaModel = $ this -> getMetaModel ( ) ; $ strTableName = $ this -> getSortingOverrideTable ( ) ; if ( $ strTableName ) { $ strColNameId = 'id' ; $ strSortColumn = $ this -> getSortingOverrideColumn ( ) ; return $ this -> connection -> createQueryBuilder ( ) -> select ( 'm.id' ) -> from ( $ metaModel -> getTableName ( ) , 'm' ) -> leftJoin ( 'm' , $ strTableName , 't' , sprintf ( 't.%s=m.%s' , $ strColNameId , $ this -> getColName ( ) ) ) -> orderBy ( 't.' . $ strSortColumn , $ strDirection ) -> execute ( ) -> fetchAll ( \ PDO :: FETCH_COLUMN , 0 ) ; } $ addWhere = $ this -> getAdditionalWhere ( ) ; $ langSet = sprintf ( '\'%s\',\'%s\'' , $ metaModel -> getActiveLanguage ( ) , $ metaModel -> getFallbackLanguage ( ) ) ; $ subSelect = $ this -> connection -> createQueryBuilder ( ) -> select ( 'z.id' ) -> from ( $ this -> getSelectSource ( ) , 'z' ) -> where ( $ this -> getLanguageColumn ( ) . 'IN(:langset)' ) -> andWhere ( 'z.' . $ this -> getIdColumn ( ) . '=m.' . $ this -> getColName ( ) ) -> orderBy ( sprintf ( 'FIELD(z.%s,%s)' , $ this -> getLanguageColumn ( ) , $ langSet ) ) -> setMaxResults ( 1 ) ; if ( $ addWhere ) { $ subSelect -> andWhere ( $ addWhere ) ; } $ sorted = $ this -> connection -> createQueryBuilder ( ) -> select ( 'm.id' ) -> from ( $ this -> getMetaModel ( ) -> getTableName ( ) , 'm' ) -> leftJoin ( 'm' , $ this -> getSelectSource ( ) , 's' , sprintf ( 's.id = (%s)' , $ subSelect -> getSQL ( ) ) ) -> where ( 'm.id IN(:ids)' ) -> orderBy ( 's.' . $ this -> getSortingColumn ( ) , $ strDirection ) -> setParameter ( 'ids' , $ idList ) -> setParameter ( 'langset' , $ langSet ) -> execute ( ) -> fetchAll ( \ PDO :: FETCH_COLUMN , 0 ) ; return $ sorted ; }
{@inheritdoc}
{