MySQL 在更新其他字段时不更新数据库中的单个字段
我正在使用 Zend Framework 1.10.8 和 MySQL Server 5.1.X。我创建数据数组来更新记录,但只有一个字段更新。
<?php
$where = "`character_id` = '5'";
$healthGained = 5;
$data = array();
if ($healthGained > 0) {
$data['character_current_health'] = $character['character_max_health'] + $healthGained;
$data['character_max_health'] = $character['character_max_health'] + $healthGained;
print_r($data);
$characterInfoTable->update($data, $where);
}
?>
我从 print_r 得到的是:
数组 ( [角色当前健康状况] =>第430章 [角色最大健康状况] =>第430章 )
但是,character_current_health 的值在数据库中不会更改。然而,character_max_health 的值确实如此。有人知道这是怎么回事吗?
注意:这些字段的命名正确并且数据类型正确。它在运行 Ubuntu 的 Linux 服务器上运行。
I am using Zend Framework 1.10.8 and MySQL Server 5.1.X. I create my data array to update the record but only one field updates.
<?php
$where = "`character_id` = '5'";
$healthGained = 5;
$data = array();
if ($healthGained > 0) {
$data['character_current_health'] = $character['character_max_health'] + $healthGained;
$data['character_max_health'] = $character['character_max_health'] + $healthGained;
print_r($data);
$characterInfoTable->update($data, $where);
}
?>
What I get from the print_r is this:
Array
(
[character_current_health] => 430
[character_max_health] => 430
)
However the value of character_current_health does not change in the database. The value of character_max_health does however. Anyone know what is going on with this?
NOTE: The fields are named correctly and are the correct data type. This is running on a Linux server running Ubuntu.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
哎呀!没关系。有时我是个白痴。它更新正确,但由于操作流程不佳,我使用错误的值重新更新了表。
Geeez! Nevermind. I am an idiot sometimes. It was updating correctly but due to a poor flow of operations, I re-updated the table with the wrong value.