PDO - 运行毫无准备的声明,包含"?"

时间:2016-08-05 13:01:13

标签: php postgresql pdo

我正在尝试在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' 
                                       ^

0 个答案:

没有答案