PHP code example of opsway / doctrine-dbal-postgresql

1. Go to this page and download the library: Download opsway/doctrine-dbal-postgresql 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/ */

    

opsway / doctrine-dbal-postgresql example snippets


$result = $this->em->createQuery(
    'SELECT l FROM Foo\Bar\Baz l WHERE CONTAINS(l.metaData, :value) = true')
    ->setParameter('value', json_encode(['foo'=>'bar']))
    ->getResult();



declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

final class VersionXXX extends AbstractMigration
{
    public function up(Schema $schema): void
    {
        $this->addSql('ALTER TABLE "user" ALTER COLUMN roles SET DATA TYPE jsonb');
    }

    public function down(Schema $schema): void
    {
        $this->addSql('ALTER TABLE "user" ALTER COLUMN roles SET DATA TYPE json');
    }
}
bash
php composer.phar 

/**
 * @var array
 *
 * @ORM\Column(type="json", nullable=true, options={"jsonb": true})
 */
private $metaData;