pixidos / doctrine-query-object
Lightweight Doctrine QueryObject imlementation
Installs: 3 488
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 1
Requires
- php: >=7.1.0
- doctrine/orm: ^2.4
This package is auto-updated.
Last update: 2024-10-29 05:46:39 UTC
README
public function withCategories(): self { $this->onPostFetch[] = function (QueryBuilder $qb, Iterator $iterator) { $qb->select('partial client.{id}')->from(Client::class, 'client') ->leftJoin('client.categories', 'categories')->addSelect('categories') ->andWhere('client.id IN (:ids)') ->setParameter('ids', $this->getIds($iterator)) ->getQuery()->getResult(); }; return $this; } public function hasCategories(array $ids): self { if (empty($ids)) { throw new LogicException(sprintf('parameter %s::$ids can not be empty', __CLASS__)); } $this->filters[] = function (QueryBuilder $qb) use ($ids) { $qb->andWhere('client.categorie IN (:catogeries)') ->setParameter('catogeries', $ids); }; return $this; } protected function doCreateQuery(QueryBuilder $queryBuilder): QueryBuilder { $queryBuilder->select('client') ->from(Client::class, 'client', 'client.id'); $this->processSelects($queryBuilder); $this->processFilters($queryBuilder); return $queryBuilder; }