Returns the SQL for custom fetching of tags with eZPersistentObject

@static

@param mixed $params
@param bool $mainTranslation
@param mixed $locale

@return string
507219
static public function fetchCustomCondsSQL( $params, $mainTranslation = false, $locale = false )
    {
        $customConds = is_array( $params ) && !empty( $params ) ? " AND " : " WHERE ";
        $customConds .= " eztags.id = eztags_keyword.keyword_id ";

        if ( $mainTranslation !== false )
        {
            $customConds .= " AND eztags.main_language_id + MOD( eztags.language_mask, 2 ) = eztags_keyword.language_id ";
        }
        else if ( is_string( $locale ) )
        {
            $db = eZDB::instance();
            $customConds .= " AND " . eZContentLanguage::languagesSQLFilter( 'eztags' ) . " ";
            $customConds .= " AND eztags_keyword.locale = '" . $db->escapeString( $locale ) . "' ";
        }
        else
        {
            $customConds .= " AND " . eZContentLanguage::languagesSQLFilter( 'eztags' ) . " ";
            $customConds .= " AND " . eZContentLanguage::sqlFilter( 'eztags_keyword', 'eztags' ) . " ";
        }

        return $customConds;
    }
1093834
public function getTransUnitList(array $locales = null, $rows = 20, $page = 1, array $filters = null)
    {
        $sortColumn = isset($filters['sidx']) ? $filters['sidx'] : 'id';
        $order = isset($filters['sord']) ? $filters['sord'] : 'ASC';

        $sortColumn = ucfirst($sortColumn);

        $query = TransUnitQuery::create()
            ->select('Id')
        ;

        $this->addTransUnitFilters($query, $filters);
        $this->addTranslationFilter($query, $locales, $filters);

        $ids = $query
            ->orderBy($sortColumn, $order)
            ->offset($rows * ($page - 1))
            ->limit($rows)
            ->find($this->getConnection())
        ;

        $transUnits = array();

        if (count($ids) > 0) {
            $unitsData = TransUnitQuery::create()
                ->filterById($ids, Criteria::IN)
                ->joinWith('Translation')
                ->useTranslationQuery()
                    ->filterByLocale($locales, Criteria::IN)
                ->endUse()
                ->orderBy($sortColumn, $order)
                ->setFormatter(ModelCriteria::FORMAT_ARRAY)
                ->find($this->getConnection())
            ;

            $transUnits = $this->filterTransUnitData($unitsData);
        }

        return $transUnits;
    }
400003
public function getUnreviewedInitialTranslations(LocaleEntity $locale)
    {
        $rs = $this->app->make(TranslationExporter::class)->getUnreviewedSelectQuery($locale);

        return $this->buildInitialTranslations($locale, $rs);
    }
444781
static public function fetchList( $params, $limits = null, $sorts = null, $mainTranslation = false, $locale = false )
    {
        $customConds = self::fetchCustomCondsSQL( $params, $mainTranslation, $locale );

        if ( is_array( $params ) )
        {
            $newParams = array();
            foreach ( $params as $key => $value )
            {
                if ( $key != 'keyword' )
                    $newParams[$key] = $value;
                else
                    $newParams['eztags_keyword.keyword'] = $value;
            }

            $params = $newParams;
        }

        if ( is_array( $sorts ) )
        {
            $newSorts = array();
            foreach ( $sorts as $key => $value )
            {
                if ( $key != 'keyword' )
                    $newSorts[$key] = $value;
                else
                    $newSorts['eztags_keyword.keyword'] = $value;
            }

            $sorts = $newSorts;
        }
        else if ( $sorts == null )
        {
            $sorts = array( 'eztags_keyword.keyword' => 'asc' );
        }

        $tagsList = parent::fetchObjectList( self::definition(), array(), $params,
                                                         $sorts, $limits, true, false,
                                                         array( 'DISTINCT eztags.*',
                                                                array( 'operation' => 'eztags_keyword.keyword',
                                                                       'name'      => 'keyword' ),
                                                                array( 'operation' => 'eztags_keyword.locale',
                                                                       'name'      => 'locale' ) ),
                                                         array( 'eztags_keyword' ), $customConds );
        return $tagsList;
    }
533805
public function getParent( $mainTranslation = false )
    {
        if ( $mainTranslation )
            return self::fetchWithMainTranslation( $this->attribute( 'parent_id' ) );

        return self::fetch( $this->attribute( 'parent_id' ) );
    }
1298855
public function getTranslation($locale = 'en_US', ConnectionInterface $con = null)
    {
        if (!isset($this->currentTranslations[$locale])) {
            if (null !== $this->collPersonFunctionI18ns) {
                foreach ($this->collPersonFunctionI18ns as $translation) {
                    if ($translation->getLocale() == $locale) {
                        $this->currentTranslations[$locale] = $translation;

                        return $translation;
                    }
                }
            }
            if ($this->isNew()) {
                $translation = new ChildPersonFunctionI18n();
                $translation->setLocale($locale);
            } else {
                $translation = ChildPersonFunctionI18nQuery::create()
                    ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
                    ->findOneOrCreate($con);
                $this->currentTranslations[$locale] = $translation;
            }
            $this->addPersonFunctionI18n($translation);
        }

        return $this->currentTranslations[$locale];
    }
1355686
public function getTranslationFile($locale)
    {
        if (isset($this->locales[$locale]) === false) {
            return null;
        }

        return $this->locales[$locale];
    }
219455
private function getSiteByLocale ($locale)
	{
		$sites = \Craft::$app->sites;

		if ($locale === null)
			return static::$sitesByOldLocale[$locale] = $sites->primarySite;

		if (array_key_exists($locale, static::$sitesByOldLocale))
			return static::$sitesByOldLocale[$locale];

		$handle = $this->locale2handle($locale);

		$siteId = (new Query())
			->select('id')
			->from(Table::SITES)
			->where(['like', 'handle', '%' . $handle])
			->column();

		if (!empty($siteId))
			return static::$sitesByOldLocale[$locale] = $sites->getSiteById($siteId[0]);

		return static::$sitesByOldLocale[$locale] = $sites->primarySite;
	}
866008
public static function create(Locale $locale, $numTranslatable, $numApprovedTranslations)
    {
        $result = new static();
        $result->locale = $locale;
        $result->numTranslatable = (int) $numTranslatable;
        $result->numApprovedTranslations = (int) $numApprovedTranslations;

        return $result;
    }
649095
public function getTranslationsByLocalesAndDomains($locales, $domains)
    {
        $em = $this->getEntityManager();
        $qb = $em->createQueryBuilder();
        $qb
            ->select('t')
            ->from('KunstmaanTranslatorBundle:Translation', 't')
            ->andWhere('t.status != :statusstring')
            ->setParameter('statusstring', Translation::STATUS_DISABLED)
            ->orderBy('t.domain', 'ASC')
            ->addOrderBy('t.keyword', 'ASC');

        if (count($locales) > 0) {
            $qb->andWhere($qb->expr()->in('t.locale', $locales));
        }

        if (count($domains) > 0) {
            $qb->andWhere($qb->expr()->in('t.domain', $domains));
        }

        $result = $qb
            ->getQuery()
            ->getResult();

        return $result;
    }
76337
public function search($params)
    {//echo __METHOD__;var_dump($params);//exit;
        $modelNewsClassname = $this->module->model('News')->className();
        $query = $this->module->model('NewsQuery', [$modelNewsClassname]);//var_dump($query);exit;

        // for REST: select by language
        $lang_code = false;
        if (!empty($params['lang_code'])) $lang_code = $params['lang_code'];
        if (!empty($params['lang']))      $lang_code = $params['lang'];
        if (!empty($lang_code)) {
            //$config = Module::getModuleConfigByClassname(Module::className());
            //$langHelper = new $config['params']['langHelper'];
            $module = Module::getModuleByClassname(Module::className());
            $langHelper = $module->langHelper;

            if ($langHelper::isValidLangCode($lang_code)) {
                $query->langCodeMain = $langHelper::normalizeLangCode($lang_code);
            }//var_dump($query->langCodeMain);exit;
        }

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        $query->andFilterWhere([
            'main.id' => $this->id, //ambiguous: 'id' => $this->id,
            'owner_id' => $this->owner_id,
            'is_visible' => $this->is_visible,
            'show_from_time' => $this->show_from_time,
            'show_to_time' => $this->show_to_time,
            //'create_time' => $this->create_time,
            //'update_time' => $this->update_time,
        ]);

        //$query->alias('main')->leftJoin(['i18n' => NewsI18n::tableName()], "main.id = i18n.news_id AND i18n.lang_code = '{$this->langCodeMain}'");

        //$query->andFilterWhere(['like', 'image', $this->image]);

        $query->andFilterWhere(['like', 'title', $this->title]);
        $query->andFilterWhere(['like', 'body', $this->body]);

        $query
            ->andFilterWhere(['>=', 'show_from_time'
                , $this->show_from_time_begin ? $this->show_from_time_begin . ' 00:00:00' : null])
            ->andFilterWhere(['<=', 'show_from_time'
                , $this->show_from_time_end ? $this->show_from_time_end . ' 23:59:59' : null])
            ->andFilterWhere(['>=', 'show_to_time'
                , $this->show_to_time_begin ? $this->show_to_time_begin . ' 00:00:00' : null])
            ->andFilterWhere(['<=', 'show_to_time'
                , $this->show_to_time_end ? $this->show_to_time_end . ' 23:59:59' : null])
            ;

        $dataProvider->sort->attributes['title'] = [
            'asc'  => ['title' => SORT_ASC],
            'desc' => ['title' => SORT_DESC],
        ];

        if (empty($params['sort'])) {
            //$query->orderBy(['show_from_time' => SORT_DESC]); // default order
            $query->orderBy($this->defaultOrderBy);
        }
            
        //list($sql, $sqlParams) = Yii::$app->db->getQueryBuilder()->build($query);var_dump($sql);var_dump($sqlParams);exit;
        return $dataProvider;
    }
1077270
public function search($params)
    {
        $this->load($params);
        $query = City::find();
        $query->select(['*', 'name' => 'city_translation.name', 'language' => 'city.language_id']);

        $query->leftJoin('city_translation', 'city_translation.city_id=city.id');
        //$query->andWhere(['city.language_id' => 'city_translation.language_id']);
        //   $query->joinWith('city');
        //    $query->joinWith('city.localisedIdentification');

        if (isset($this->uid)) {
            $this->pageSize = 1;
        }

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'pagination' => ($this->pagination ? [
                'pageSize' => $this->pageSize,
                    ] : FALSE),
            'sort' => [
                'attributes' => [
                    'name', 'postcode', 'language'
                ],
            ]
        ]);
        if (isset($this->uid)) {
            // uncomment the following line if you do not want to return any records when validation fails
            $query->where(['uid' => $this->uid]);
            return $dataProvider;
        }
        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            $query->where('0=1');
            return $dataProvider;
        }




        return $dataProvider;
    }
287588
static public function fetchByKeyword( $keyword, $mainTranslation = false )
    {
        return self::fetchList( array( 'keyword' => $keyword ), null, null, $mainTranslation );
    }
218403
public function getHelpTextByKeyLocale($translationKey, $locale)
    {
        $qb = $this->createQueryBuilder('h');
        $qb->where('h.locale LIKE :locale')
            ->andWhere('h.translationKey LIKE :translationKey')
            ->orderBy('h.id', 'asc')
            ->setParameter(':locale', substr($locale, 0, 2).'%')
            ->setParameter(':translationKey', $translationKey.'%');

        try {
            $helpText = $qb->getQuery()->getSingleResult();
        } catch (NoResultException $e) {
            $qb = $this->createQueryBuilder('h');
            $qb->where('h.locale LIKE :locale')
                ->andWhere('h.translationKey = :translationKey')
                ->orderBy('h.id', 'asc')
                ->setParameter(':locale', substr($locale, 0, 2).'%')
                ->setParameter(':translationKey', 'not_found');
            $helpText = $qb->getQuery()->getSingleResult();
        }

        return $helpText;
    }
1076380
protected function getTranslatedQuery(QueryBuilder $qb, $locale = null)
    {
        $query = $this->setTranslationHints($qb->getQuery(), $locale);

        return $query;
    }
1058703
private function getProductQuery($locale)
    {
        $qb = $this->createQueryBuilder('product')
            ->addSelect('prices')
            ->addSelect('parent')
            ->addSelect('translations')
            ->addSelect('status')
            ->addSelect('type')
            ->addSelect('currency')
            ->addSelect('media')
            ->leftJoin('product.parent', 'parent')
            ->leftJoin('product.translations', 'translations', 'WITH', 'translations.locale = :locale')
            ->leftJoin('product.status', 'status')
            ->leftJoin('status.translations', 'statusTranslations', 'WITH', 'statusTranslations.locale = :locale')
            ->leftJoin('product.type', 'type')
            ->leftJoin('product.prices', 'prices')
            ->leftJoin('prices.currency', 'currency')
            ->leftJoin('product.media', 'media')
            ->setParameter('locale', $locale);

        return $qb;
    }
1134584
public function getAll($locale)
    {
        $qb = $this->createQueryBuilder('r');

        $qb->addSelect('t');
        $qb->innerJoin('r.translations', 't');
        $qb->andWhere('t.locale=:locale');
        $qb->setParameter(':locale', $locale);

        return $qb->getQuery()->execute();
    }