You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

pg_update生成重复表名查询致relation不存在问题求助

pg_update函数生成错误表名的问题

运行以下PHP代码:

$result = pg_update(    
    $conn, "schema.table", 
    array( 
        'thing' => "value"
    ), 
    array( 
        'condition' => "otherthing"
    )
);

收到警告:

PHP Warning:  pg_update(): ERROR:  relation "schema.table.table" does not exist
LINE 1: UPDATE "schema.table"."table...
               ^

添加PGSQL_DML_STRING参数后,生成的查询语句为:

UPDATE "schema.table"."table" SET "thing"='value' WHERE "condition"='otherthing';

可以看到函数错误生成了"schema.table"."table",而非正确的"schema"."table"。若仅传入表名table,会提示“Table does not exist”,但相同结构的其他数据库环境中可正常运行。

补充信息

  • 连接字符串已包含数据库名:
$connstring = "dbname=".$DB_DATABASE." user=".$DB_USER." port=".$DB_PORT." host=".$DB_SERVER
  • 正常与异常服务器的数据库名称一致
  • 正常服务器版本:
    • PHP 8.3.2-1+020240120.16+debian121.gbpb43448
    • PostgreSQL 15.8 (Debian 15.8-0+deb12u1)
    • 搜索路径:"$user", public
  • 异常服务器版本:
    • PHP 8.3.3-1+020240216.17+debian111.gbp87e37b
    • PostgreSQL 15.3 (Debian 15.3-0+deb12u1)
    • 搜索路径:"$user", public

内容的提问来源于stack exchange,提问作者oldslow

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 05:34:55