1. Go to this page and download the library: Download boldtrn/jsonb-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
boldtrn / jsonb-bundle example snippets
/**
* @Entity
*/
class Test
{
/**
* @Id
* @Column(type="string")
* @GeneratedValue
*/
public $id;
/**
* @Column(type="jsonb")
*
* Usually attrs is an array, depends on you
*
*/
public $attrs = array();
}
$q = $this
->entityManager
->createNativeQuery(
"
SELECT t.id, t.attrs
FROM Test t
WHERE t.attrs @> 'value'
"
, $rsm);
$q = $this
->entityManager
->createQuery(
"
SELECT t
FROM E:Test t
WHERE JSONB_AG(t.attrs, 'value') = TRUE
"
);
$q = $this
->entityManager
->createQuery(
"
SELECT t
FROM E:Test t
WHERE JSONB_HGG(t.attrs , '{\"b\",\"c\"}') LIKE '%d%'
"
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.