gpt4 book ai didi

php - 将时间戳类型与 pg_prepare 一起使用

转载 作者:行者123 更新时间:2023-11-29 14:02:33 25 4
gpt4 key购买 nike

运行以下代码:

$preCallMatch = pg_prepare($dbcp, 'callMatch',
"SELECT duration
FROM voip_calls
WHERE system_id = $1
AND call_start => $2
AND call_start <= $3
AND destination = $4");

我收到以下错误:

Warning: pg_prepare(): Query failed: ERROR:  operator does not exist: timestamp without time zone => "unknown"
HINT: No operator matches the given name and argument type(s). You may need to add explicit type casts. in /home/www/dinesh/UPSReconcileZeroSecondCalls.php on line 38

我曾尝试以这种方式 throw $2 但没有成功:

$preCallMatch = pg_prepare($dbcp, 'callMatch',
"SELECT duration
FROM voip_calls
WHERE system_id = $1
AND call_start => CAST ( $2 AS TIMESTAMP )
AND call_start <= CAST ( $3 AS TIMESTAMP )
AND destination = $4");


Warning: pg_prepare(): Query failed: ERROR: operator does not exist: timestamp without time zone => timestamp without time zone
HINT: No operator matches the given name and argument type(s). You may need to add explicit type casts. in /home/www/dinesh/UPSReconcileZeroSecondCalls.php on line 38

voip_calls 表中的列类型:

call_start     | timestamp without time zone |
call_end | timestamp without time zone | not null

关于我做错了什么的任何提示?请注意,PDO 或 MDPD 目前不是一个选项。

软件版本:

ii  php5                            5.2.6.dfsg.1-1+lenny3      server-side, HTML-embedded scripting languag
ii libapache2-mod-php5 5.2.6.dfsg.1-1+lenny3 server-side, HTML-embedded scripting languag
ii php5-pgsql 5.2.6.dfsg.1-1+lenny3 PostgreSQL module for php5
ii libpq5 8.3.8-0lenny1 PostgreSQL C client library
postmaster (PostgreSQL) 8.1.4

最佳答案

可能是您的 => 运算符导致了问题 - 请尝试改用 >=。

还有一个提示,我发现写 $2::timestamp 而不是 CAST($2 AS TIMESTAMP) 更容易——它是一种 PostgreSQL 特定的语法,但对我来说读起来更好(而且输入更少 ;-) )

关于php - 将时间戳类型与 pg_prepare 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2332536/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com