Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

479
Visualizações
How to use JSONB_ARRAY_ELEMENTS function in QueryBuilder with Symfony?

I try to use functions provided by https://github.com/martin-georgiev/postgresql-for-doctrine/ but Symfony returns this error :

Error: Class 'JSONB_ARRAY_ELEMENTS' is not defined.

Here is the code of my function in the repository file:

$query = $this->createQueryBuilder('p')
              ->from('JSONB_ARRAY_ELEMENTS(CAST(p.wp_syncs AS JSONB))', 'pwps')
              ->getQuery()
              ->getResult();

The function is activated in doctrine.yaml:

dql:
    string_functions:
        # ...
        JSONB_ARRAY_ELEMENTS: MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\JsonbArrayElements
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You can’t set a function or a subquery in the FROM clause of a Doctrine DQL query.

You should write a SQL query instead:

$connection = $entityManager->getConnection(); // Get the DBAL connection

// Create a DBAL Query builder.
// Note that this query builder is NOT the same of the query builder returned by the EntityManager.
$qb = $connection->createQueryBuilder();

$qb->select('*')
    ->from('jsonb_array_elements(CAST(p.wp_syncs AS JSONB))', 'pwps')
    ->getQuery()
    ->getResult();

In this case you don’t need to register the function in doctrine’s configuration.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda