【问题标题】:how to prepare a query to json postgresql field in php如何在php中准备对json postgresql字段的查询
【发布时间】:2017-06-13 12:13:04
【问题描述】:

我在 PHP 中创建查询以从 postgresql 数据库中检索 json 值时遇到问题。

问题出在以下简单查询的 json WHERE 子句中

select * from json_data where jsonfield ? 'roottag';

如果我使用 PDO 准备:

$query->prepare($sqlSelect);

PDO 将翻译 ? (postgres json 运算符查看 json 字段是否以特定标记开头)到 $1。

我如何编写类似于上述的 sql 语句在 php PDO 中使用?

【问题讨论】:

  • 先阅读文档怎么样? php.net/manual/en/pdo.prepare.php
  • @FelippeDuarte 抱歉,我确实阅读了该页面,但不明白如何避免 prepare() 翻译“?”

标签: php json postgresql


【解决方案1】:

为了保护其他人的安全:补丁正在开发中!(在撰写本文时)

见:https://github.com/php/php-src/pull/1967

【讨论】:

    猜你喜欢
    • 2021-07-04
    • 2015-04-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-15
    相关资源
    最近更新 更多