【发布时间】:2015-05-31 17:19:59
【问题描述】:
我有这个查询,无论$relocation['persons_id'] 是什么,都将residents 更新为1。
以下代码将在此示例中回显11,13,但将residents 设置为1:
$query = $db->prepare('UPDATE `apartments` SET `residents` = :persons_id AND `occupation_date` = :occupation_date WHERE `id` = :apartments_id');
echo $relocation['persons_id']."<br>\n";
$query->bindParam(':persons_id', $relocation['persons_id']);
$query->bindParam(':occupation_date', $relocation['occupation_date']);
$query->bindParam(':apartments_id', $relocation['apartments_id']);
$query->execute();
字段residents 的数据类型为varchar(200)。
你能解释一下我做错了什么吗?
【问题讨论】:
-
尝试将数据类型转换为 int (11) 并检查一次。请
-
输出是什么:
echo $relocation['persons_id'] -
@Rizier123 如问题 11,13 所述
-
@anant kumar singh 当我尝试插入一个字符串时,int 可能是不可能的。
标签: php mysql pdo prepared-statement