add select if

  public function getPosTypeNameByActive(): array
    {
        $query = $this->connection->createQueryBuilder();
        $query->select($this->getAlias() . '.name')
            ->addSelect(
                'IF (cf.id IS NOT NULL AND (:dateNow >= cf.date_from AND :dateNow <= cf.date_to), 1, 0) as active'
            )
            ->leftJoin(
                $this->getAlias(),
                'cycle',
                'c',
                sprintf('c.id = %s.cycle_id', $this->getAlias())
            )
            ->leftJoin(
                $this->getAlias(),
                'cycle_flat',
                'cf',
                sprintf('cf.cycle_id = %s.cycle_id', $this->getAlias())
            )
            ->setParameter('dateNow', ActualDate::get()->format('Y-m-d H:i:s'), PDO::PARAM_STR)
            ->resetQueryPart('from')->from($this->getTableName(), $this->getAlias())
            ->having('active = 1');

        return $query->execute()->fetchAll(PDO::FETCH_COLUMN);
    }
Komentarze wyłączone