<?php
// 使用PDO链接
$pdo = new PDO("pgsql:host=127.0.0.1;port=5432;dbname=postgres","postgres","");
$statement = $pdo->prepare("select * from test where account::jsonb ? '111'");
$statement->execute();
var_dump($statement->errorInfo());
$rs = $statement->fetch();
var_dump($rs);
// 原生链接 查询
$p = pg_connect("host=127.0.0.1 port=5432 dbname=postgres user=yluchao password=''");
$rs = pg_query($p, "select * from test where account::jsonb ? '111'");
var_dump(pg_fetch_all($rs));
/*create table test
(
id bigserial primary key,
account jsonb not null default '{}',
name varchar(255) not null default ''
);*/
如图 使用pdo查询报错,使用原生的pgsql链接则可以查询
慕无忌1623718