PHP code example of martin-georgiev / postgresql-for-doctrine
1. Go to this page and download the library: Download martin-georgiev/postgresql-for-doctrine 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/ */
martin-georgiev / postgresql-for-doctrine example snippets
// Register types with Doctrine
Type::addType('jsonb', "MartinGeorgiev\\Doctrine\\DBAL\\Types\\Jsonb");
Type::addType('text[]', "MartinGeorgiev\\Doctrine\\DBAL\\Types\\TextArray");
// Use in your Doctrine entities
#[ORM\Column(type: 'jsonb')]
private array $data;
#[ORM\Column(type: 'text[]')]
private array $tags;
// Use in DQL
$query = $em->createQuery('
SELECT e
FROM App\Entity\Post e
WHERE CONTAINS(e.tags, ARRAY[:tags]) = TRUE
AND JSON_GET_FIELD(e.data, :field) = :value
');