symfony mapowanie na inty w zapytaniu

    public function gettt(int $serviceId): array
    {
        $query = $this->connection->prepare(
            'SELECT s_id FROM somefing_has shcs WHERE xxxx =:xxxx'
        );
        $query->bindParam('xxxx', $xxxx, PDO::PARAM_INT);
        $query->execute();

        return array_map('intval', $query->fetchAll(PDO::FETCH_COLUMN));
    }

lub

return array_column($qb->getQuery()->getResult(Query::HYDRATE_ARRAY), 'nazwa_col');

lub

        $queryBuilder = $this->connection->createQueryBuilder();
        /** @var PDOConnection $pdo */
        $pdo = $this->connection->getWrappedConnection();
        $oldAttributeValue = $pdo->getAttribute(PDO::ATTR_EMULATE_PREPARES);
        $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);

        $queryBuilder
            ->select('DISTINCT(orr.order_id)')
            ->from('order_related', 'orr')
            ->innerJoin('orr', '`order`', 'o', 'orr.order_related_id = o.id')
            ->where('o.id IN (SELECT id FROM `order` WHERE unique_hash = :uniqueHash)')
            ->setParameter('uniqueHash', $orderUniqueHash, PDO::PARAM_STR);

        $stmt = $queryBuilder->execute();
        $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, $oldAttributeValue);

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