gpt4 book ai didi

php - bitvalue 为 false 时出现 PostgreSQL 错误

转载 作者:行者123 更新时间:2023-11-29 12:47:26 25 4
gpt4 key购买 nike

我在使用 PDO 将位值保存到我的 PostgreSQL-DB 时遇到了一些麻烦。每当位( bool )为假时,我都会收到此错误

Warning: PDOStatement::execute(): SQLSTATE[22026]: String data, length mismatch: 7 
ERROR: bit string length 0 does not match type bit(1) in /var/www/html/application/models/Database.php on line 75

显示的代码有点复杂,但这里是进入 DB 类的内容。

UPDATE users SET name=:name,email=:email,address=:address,zip=:zip,joindate=:joindate,phone=:phone,password=:password,activationcode=:activationcode,birthdate=:birthdate,lastdigits=:lastdigits,driverlicense=:driverlicense,e_presentation=:e_presentation,e_showphone=:e_showphone,e_showaddress=:e_showaddress,e_radius=:e_radius,e_showinsearch=:e_showinsearch,w_presentation=:w_presentation,w_showphone=:w_showphone,w_showaddress=:w_showaddress,w_radius=:w_radius,w_showinsearch=:w_showinsearch WHERE id=:id

以及绑定(bind)参数的数据

Array ( [:name] => My Name [:email] => myemail@gmail.com [:address] => My Address [:zip] => 79133 [:joindate] => 2012-09-18 12:39:56.769584 [:phone] => 073 917 13 97 [:password] => c6d18ac44b378ff3cecf09d9ebec31ad301c4394d7e1sdfjksc81cd3fbf47777f8df0ac9f33d14da18d71b76fc9c3e1210cb2efcabf6ed66f779d [:activationcode] => [:birthdate] => 1993-08-05 [:lastdigits] => 5079 [:driverlicense] => 0 [:e_presentation] => Test [:e_showphone] => 1 [:e_showaddress] => 1 [:e_radius] => 10 [:e_showinsearch] => 1 [:w_presentation] => Test [:w_showphone] => 1 [:w_showaddress] => 1 [:w_radius] => 10 [:w_showinsearch] => 1 [:id] => 28 ) 1

Google 快速搜索显示其他人也有同样的问题,但没有解决方案。

最佳答案

也许您可以使用 boolean 获得更好的服务键入而不是 bit(1)

如果您确实需要将 boolean 值转换为 bit(1),则直接转换不起作用:

<strike>select FALSE::bit(1), TRUE::bit(1)</strike>

但这行得通:

select FALSE::int::bit(1), TRUE::int::bit(1)

首先转换为整数,然后转换为

关于php - bitvalue 为 false 时出现 PostgreSQL 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12539460/

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