I've this column in MySql:
male BOOLEAN COMMENT "true for male",
我正在使用此查询在_1526958中使用PDO包装器进行插入:
$id = db_insert('Person')->fields(array(
.......
'male' => false,
)
)->execute();
I'm getting this error:
WD php:PDOException:SQLSTATE [HY000]:一般错误:1366不正确^ [[31; 40m ^ [[1m [错误] ^ [[0m整数值:''对于第1行的列'male':INSERT INTO . ....
但是如果我用 'male'=>true
替换,则查询有效 . 令人惊讶的是,如果我用 false
替换 0
或 (int)false
那么它也有效!
这意味着在此上下文中将false转换为''(空字符串) .
I'd like to know why it's getting converted to a string here.
我在这里有相关的问题:In PHP why is true cast 1 and false cast an empty string?但它没有回答为什么PHP将false转换为字符串?