Skip to content

Instantly share code, notes, and snippets.

@grizmio
Created December 29, 2020 00:02
Show Gist options
  • Select an option

  • Save grizmio/607300a94f99ec99dcdfb0ebd4c5e423 to your computer and use it in GitHub Desktop.

Select an option

Save grizmio/607300a94f99ec99dcdfb0ebd4c5e423 to your computer and use it in GitHub Desktop.
Symfony Doctrine jsonb columns postgresql operators with escape ? character since php 7.4
<?php
$v = "foobar.baz";
$rsm = new \Doctrine\ORM\Query\ResultSetMappingBuilder($this->_em);
$rsm->addRootEntityFromClassMetadata(Bazar::class, 't_alias');
$query = $this->_em->createNativeQuery("select * from t td where t.foo ??| :v order by id asc", $rsm);
$query->setParameter("v", $v);
$v = ["asd", "qwert"];
$v_s = '{"'.implode('","', $v).'"}';
$query = $this->_em->createNativeQuery("select * from t where t.x ?? ? order by id asc", $rsm);
$query->setParameter(1, $v_s);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment