我正在尝试在PostgreSQL数据库上运行select查询,以检查是否存在json字段:
SELECT * FROM users WHERE meta ? 'linked_accounts'
然而,PDO不允许我以原始方式执行它:
<?php
$pdo = DB::connection()->getPdo();
$query = $pdo->query( "SELECT * FROM users WHERE meta ? 'linked_accounts'" );
$users = $query->fetchAll();
例外:
[PDOException]
SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "$1"
LINE 1: SELECT * FROM users WHERE meta $1 'linked_accounts'
^