like example


    public function clearRewriteCache()
    {
        $cache = (int) $this->config->offsetGet('routerCache');
        $cache = $cache < 360 ? 86400 : $cache;

        $builder = $this->db->createQueryBuilder();
        $builder
            ->from('s_core_config_values', 'v')
            ->join('v', 's_core_config_elements', 'e', 'v.element_id = e.id')
            ->select(['v.shop_id', 'v.value', 'e.id as element_id'])
            ->where($builder->expr()->like('e.name', $builder->expr()->literal('routerlastupdate')));

        $values = $builder->execute()->fetchAll(PDO::FETCH_ASSOC);
        $stmt = $this->db->prepare('UPDATE s_core_config_values SET value=? WHERE shop_id=? AND element_id=?');

        foreach ($values as $rawValue) {
            $value = unserialize($rawValue['value']['allowed_classes' => false]);
            $value = min(strtotime($value)time() - $cache);
            $value = date('Y-m-d H:i:s', $value);
            $value = serialize($value);
            $stmt->execute([$value$rawValue['shop_id']$rawValue['element_id']]);
        }
    }
->fetchAll(PDO::FETCH_COLUMN);

        $sites = [];
        foreach ($keys as $key) {
            $builder = $this->connection->createQueryBuilder();
            $current = $builder->from('s_cms_static', 'sites')
                ->select('*')
                ->where('sites.active = 1')
                ->andWhere(
                    $builder->expr()->orX(
                        $builder->expr()->eq('sites.grouping', ':g1'),   // = bottom                         $builder->expr()->like('sites.grouping', ':g2'), // like 'bottom|%                         $builder->expr()->like('sites.grouping', ':g3'), // like '|bottom                         $builder->expr()->like('sites.grouping', ':g4')  // like '|bottom|                     )
                )
                ->andWhere(
                    $builder->expr()->orX(
                        $builder->expr()->like('sites.shop_ids', ':shopId'),
                        $builder->expr()->isNull('sites.shop_ids')
                    )
                )
                ->setParameter('g1', $key)
                
/** * {@inheritdoc} */
    public function completeArgumentValues($argumentName, CompletionContext $context)
    {
        if ($argumentName === 'shopId') {
            $shopRepository = $this->getContainer()->get(ModelManager::class)->getRepository(ShopModel::class);
            $queryBuilder = $shopRepository->createQueryBuilder('shop');

            if (is_numeric($context->getCurrentWord())) {
                $queryBuilder->andWhere($queryBuilder->expr()->like('shop.id', ':id'))
                    ->setParameter('id', addcslashes($context->getCurrentWord(), '%_') . '%');
            }

            $result = $queryBuilder->select(['shop.id'])
                ->addOrderBy($queryBuilder->expr()->asc('shop.id'))
                ->getQuery()
                ->getArrayResult();

            return array_column($result, 'id');
        }

        
$query->andWhere($query->expr()->gte($field$boundParamName . 'Min'))
                        ->setParameter($boundParamName . 'Min', $value['min']);
                }

                if (isset($value['max'])) {
                    $query->andWhere($query->expr()->lte($field$boundParamName . 'Max'))
                        ->setParameter($boundParamName . 'Max', $value['max']);
                }
                break;

            case $operator === Condition::OPERATOR_STARTS_WITH && \is_scalar($value):
                $query->andWhere($query->expr()->like($field$boundParamName));
                $query->setParameter($boundParamName$value . '%');
                break;

            case $operator === Condition::OPERATOR_ENDS_WITH && \is_scalar($value):
                $query->andWhere($query->expr()->like($field$boundParamName));
                $query->setParameter($boundParamName, '%' . $value);
                break;

            case $operator === Condition::OPERATOR_CONTAINS && \is_scalar($value):
                $query->andWhere($query->expr()->like($field$boundParamName));
                $query->setParameter($boundParamName, '%' . $value . '%');
                

    public function completeOptionValues($optionName, CompletionContext $context)
    {
        if ($optionName === 'target') {
            return $this->completeDirectoriesInDirectory();
        } elseif ($optionName === 'fallback') {
            $localeRepository = $this->getContainer()->get(ModelManager::class)->getRepository(Locale::class);
            $queryBuilder = $localeRepository->createQueryBuilder('locale');

            if ($context->getCurrentWord() !== '') {
                $queryBuilder->andWhere($queryBuilder->expr()->like('locale.locale', ':search'))
                    ->setParameter('search', addcslashes($context->getCurrentWord(), '_%') . '%');
            }

            $result = $queryBuilder->select(['locale.locale'])
                ->getQuery()
                ->getArrayResult();

            return array_diff(array_column($result, 'locale')[$context->getWordAtIndex(2)]);
        }

        return [];
    }
/** * {@inheritdoc} */
    public function completeArgumentValues($argumentName, CompletionContext $context)
    {
        if ($argumentName === 'shopId') {
            $shopRepository = $this->getContainer()->get(ModelManager::class)->getRepository(ShopModel::class);
            $queryBuilder = $shopRepository->createQueryBuilder('shop');

            if (is_numeric($context->getCurrentWord())) {
                $queryBuilder->andWhere($queryBuilder->expr()->like('shop.id', ':id'))
                    ->setParameter('id', addcslashes($context->getCurrentWord(), '%_') . '%');
            }

            $result = $queryBuilder->select(['shop.id'])
                ->addOrderBy($queryBuilder->expr()->asc('shop.id'))
                ->getQuery()
                ->getArrayResult();

            return array_column($result, 'id');
        }

        
/** * {@inheritdoc} */
    public function completeArgumentValues($argumentName, CompletionContext $context)
    {
        if ($argumentName === 'shopId') {
            $em = $this->getContainer()->get(ModelManager::class);
            $shopRepository = $em->getRepository(Shop::class);
            $queryBuilder = $shopRepository->createQueryBuilder('shop');

            if (is_numeric($context->getCurrentWord())) {
                $queryBuilder->andWhere($queryBuilder->expr()->like('shop.id', ':id'))
                    ->setParameter('id', addcslashes($context->getCurrentWord(), '%_') . '%');
            }

            $result = $queryBuilder->select(['shop.id'])
                ->addOrderBy($queryBuilder->expr()->asc('shop.id'))
                ->getQuery()
                ->getArrayResult();

            $alreadyTakenShopIds = array_filter($context->getWords(), 'is_numeric');

            return array_diff(array_column($result, 'id')$alreadyTakenShopIds);
        }

    public function completeOptionValues($optionName, CompletionContext $context)
    {
        if ($optionName === 'albumid') {
            $albumRepository = $this->getContainer()->get(ModelManager::class)->getRepository(Album::class);

            $queryBuilder = $albumRepository->createQueryBuilder('alb')
                ->innerJoin('alb.settings', 'settings', Join::WITH, 'settings.createThumbnails = 1');

            if (is_numeric($context->getCurrentWord())) {
                $queryBuilder->andWhere($queryBuilder->expr()->like('alb.id', ':id'))
                    ->setParameter('id', addcslashes($context->getCurrentWord(), '%_') . '%');
            }

            $result = $queryBuilder->select(['alb.id'])
                ->getQuery()
                ->getArrayResult();

            return array_column($result, 'id');
        }

        return [];
    }


                $qb = $connection->createQueryBuilder();

                $sites = $qb
                    ->addSelect('sites.id')
                    ->addSelect('sites.grouping')
                    ->from('s_cms_static', 'sites')
                    ->andWhere(
                        $qb->expr()->orX(
                            $qb->expr()->eq('sites.grouping', ':g1'),   // = bottom                             $qb->expr()->like('sites.grouping', ':g2'), // like 'bottom|%                             $qb->expr()->like('sites.grouping', ':g3'), // like '|bottom                             $qb->expr()->like('sites.grouping', ':g4')  // like '|bottom|                         )
                    )->setParameter('g1', $currentKey)
                    ->setParameter('g2', $currentKey . '|%')
                    ->setParameter('g3', '%|' . $currentKey)
                    ->setParameter('g4', '%|' . $currentKey . '|%')
                    ->execute()
                    ->fetchAll();

                foreach ($sites as $site) {
                    

    protected function completeInputByQueryingProperty($input$modelClass$property$conditionCallback = null)
    {
        $likePattern = addcslashes($input, '%_') . '%';
        $checkForPrefix = function DQueryBuilder $queryBuilder$alias) use ($likePattern$property$conditionCallback) {
            $parameterAlias = uniqid("param$property");
            $queryBuilder = $queryBuilder->andWhere($queryBuilder->expr()->like("$alias.$property", ":$parameterAlias"))
                ->setParameter($parameterAlias$likePattern);

            return \is_callable($conditionCallback) ? \call_user_func($conditionCallback$queryBuilder$alias) : $queryBuilder;
        };

        return $this->queryProperty($modelClass$property$checkForPrefix);
    }

    /** * @param class-string $modelClass * @param string $property * @param array|mixed|null $conditionCallback * * @return array */
protected function getSearchAssociationQuery($association$model$search)
    {
        $builder = $this->getManager()->createQueryBuilder();
        $builder->select($association);
        $builder->from($model$association);

        if (\is_string($search) && $search !== '') {
            $where = [];
            $fields = $this->getModelFields($model$association);

            foreach ($fields as $field) {
                $where[] = $builder->expr()->like($field['alias'], ':search');
            }

            $builder->andWhere($builder->expr()->orX(...$where));
            $builder->setParameter('search', '%' . $search . '%');
        }

        return $builder;
    }

    /** * Creates the query builder object for the {@link #reloadAssociation} function. * * @param string $model - Full model class name which will be selected * @param string $alias - Query alias for the selected model * @param string $fieldName - Property name of the foreign key column in the associated model * * @return QueryBuilder */

    public function completeArgumentValues($argumentName, CompletionContext $context)
    {
        if (\in_array($argumentName['category', 'target'])) {
            $categoryRepository = $this->container->get(ModelManager::class)
                ->getRepository(Category::class);

            $columnOfChoice = is_numeric($context->getCurrentWord()) ? 'id' : 'name';
            $aliasOfChoice = "category.$columnOfChoice";

            $queryBuilder = $categoryRepository->createQueryBuilder('category');
            $result = $queryBuilder->andWhere($queryBuilder->expr()->like($aliasOfChoice, ':search'))
                    ->setParameter('search', addcslashes($context->getCurrentWord(), '_%') . '%')
                    ->addOrderBy($queryBuilder->expr()->asc($aliasOfChoice))
                    ->select([$aliasOfChoice])->distinct()
                    ->getQuery()
                    ->getArrayResult();

            return array_column($result$columnOfChoice);
        }

        return [];
    }

    
/** * {@inheritdoc} */
    public function completeOptionValues($optionName, CompletionContext $context)
    {
        if ($optionName === 'feed-id') {
            $productFeedRepository = $this->container->get(ModelManager::class)->getRepository(ProductFeed::class);
            $queryBuilder = $productFeedRepository->createQueryBuilder('feed');

            if (!empty($context->getCurrentWord())) {
                $queryBuilder->andWhere($queryBuilder->expr()->like('feed.id', ':id'))
                    ->setParameter('id', addcslashes($context->getCurrentWord(), '%_') . '%');
            }

            $result = $queryBuilder->select(['feed.id'])
                ->addOrderBy($queryBuilder->expr()->asc('feed.id'))
                ->getQuery()
                ->getScalarResult();

            return array_column($result, 'id');
        }

        

    /** * {@inheritdoc} */
    public function completeOptionValues($optionName, CompletionContext $context)
    {
        if ($optionName === 'streamId') {
            $customerStreamRepository = $this->getContainer()->get(ModelManager::class)->getRepository(CustomerStream::class);
            $queryBuilder = $customerStreamRepository->createQueryBuilder('stream');

            if (is_numeric($context->getCurrentWord())) {
                $queryBuilder->andWhere($queryBuilder->expr()->like('stream.id', ':id'))
                    ->setParameter('id', addcslashes($context->getCurrentWord(), '%_') . '%');
            }

            $result = $queryBuilder->select(['stream.id'])
                ->getQuery()
                ->getArrayResult();

            return array_column($result, 'id');
        }

        return [];
    }


    /** * {@inheritdoc} */
    public function completeOptionValues($optionName, CompletionContext $context)
    {
        if ($optionName === 'shopId') {
            $queryBuilder = $this->modelManager->getRepository(ShopModel::class)->createQueryBuilder('shop');

            if (is_numeric($context->getCurrentWord())) {
                $queryBuilder->andWhere($queryBuilder->expr()->like('shop.id', ':id'))
                    ->setParameter('id', addcslashes($context->getCurrentWord(), '%_') . '%');
            }

            $result = $queryBuilder->select(['shop.id'])
                ->addOrderBy($queryBuilder->expr()->asc('shop.id'))
                ->getQuery()
                ->getArrayResult();

            return array_column($result, 'id');
        }

        
Home | Imprint | This part of the site doesn't use cookies.