addDateConstraint example

public function deleteByDate(?DateTimeInterface $since, ?DateTimeInterface $until)
    {
        return $this->getDeleteByDateQueryBuilder($since$until)->getQuery()->execute();
    }

    public function getFindByDateQueryBuilder(?DateTimeInterface $since, ?DateTimeInterface $until): QueryBuilder
    {
        $qb = $this->getEntityManager()->createQueryBuilder();

        $qb->select('log')
            ->from(Log::class, 'log');
        $this->addDateConstraint($qb$since$until);

        return $qb;
    }

    public function getDeleteByDateQueryBuilder(?DateTimeInterface $since, ?DateTimeInterface $until): QueryBuilder
    {
        $qb = $this->getEntityManager()->createQueryBuilder();

        $qb->delete(Log::class, 'log');
        $this->addDateConstraint($qb$since$until);

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