【发布时间】:2021-08-18 16:09:55
【问题描述】:
- Laravel 版本:8.44.0
- PHP 版本:7.4.19
- 数据库驱动程序和版本:带有 pgBouncer 的 PostgreSQL 13.3
说明:
在 PostgreSQL 数据库上使用 save() 方法和 \PDO::ATTR_EMULATE_PREPARES => true 时,DB 连接在 prepareBindings 和 bindValues 方法中将布尔值转换为整数。
复制步骤:
User::create([
'name' => 'Laravel user',
'password' => 'password',
'is_suspended' => false,
]);
错误:SQLSTATE[42804]: Datatype mismatch: 7 ERROR: column "is_suspended" is of type boolean but expression is of type integer
【问题讨论】:
-
玩具试过 protected $casts = [ 'is_suspended' => 'boolean', ];在你的模型中
-
已经试过了。不工作
-
为我工作:Laravel 8.36.2 Php 7.5.3 Postgresql 12.7 PgBouncer No
标签: php laravel postgresql eloquent