[英]Can I use the PostgreSQL simple query mode with PHP/PDO?
Postgres supports both a simple and extended "query mode". Postgres 支持简单和扩展的“查询模式”。
With JDBC I can use preferQueryMode=simple
to force the driver to use simple mode when issuing queries.使用JDBC,我可以使用
preferQueryMode=simple
强制驱动程序在发出查询时使用简单模式。
How can I do the same with PDO and the PDO_PGSQL extension in PHP?我怎样才能对 PDO 和 PHP 中的 PDO_PGSQL 扩展做同样的事情? The server I am currently querying (a PgBouncer instance, to retrieve stats) does not support extended mode queries, and all of my queries (issued via Symfony/Doctrine) fail with a
ERROR: unsupported pkt type: 80
error.我目前查询(一PgBouncer例如,检索数据)不支持扩展模式的查询服务器,以及所有我的查询(通过的Symfony /学说发行)失败与
ERROR: unsupported pkt type: 80
的错误。
Setting the PDO::ATTR_EMULATE_PREPARES
flag to be enabled is enough to prevent extended mode queries from being issued, it seems. PDO::ATTR_EMULATE_PREPARES
将PDO::ATTR_EMULATE_PREPARES
标志设置为启用足以防止发出扩展模式查询。
In Symfony you do this by adding an option to the Doctrine YAML config under the relevant connection:在 Symfony 中,您可以通过在相关连接下的 Doctrine YAML 配置中添加一个选项来完成此操作:
options:
20: true
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.