【发布时间】:2015-05-13 04:59:59
【问题描述】:
正如标题所述,我的 MySQLi 准备更新实际上并没有更新数据库。我检查了 MySQL 日志 - 没有错误。这是有问题的代码:
public function update_tweet($tweet)
{
$prepared_update = $this->connection->prepare("UPDATE Tweets
SET `text` = ?, `algo_score` = ?, `has_algo_score` = ?, `baseline_score` = ?, `has_baseline_score` = ?, `is_sanitized` = ?
WHERE `twitter_id` = ?");
mysqli_stmt_bind_param($prepared_update, "sssssss", $tweet['text'], $tweet['algo_score'], $tweet['has_algo_score'], $tweet['baseline_score'], $tweet['has_baseline_score'], $tweet['is_sanitized'], $tweet['tweet_id']);
mysqli_execute($prepared_update) or die(mysqli_error($this->connection));
$prepared_update->close();
}
以及传入的推文数组示例:
Array ( [id] => 2
[twitter_id] => 595463376026734592
[text] => History has a way of repeating itself
[algo_score] => 0
[has_algo_score] => 1
[baseline_score] => 0
[has_baseline_score] => 1
[is_sanitized] => 1
)
还有表架构:
没有 PHP 错误或 MySQL 错误。我做错了什么?
【问题讨论】:
-
检查 mySQL 查询日志以查看是否有任何实际通过?我的地址是
/usr/local/mysql/data/mysql.log。 -
感谢您的评论 - 这只是一个简单的拼写错误。菜鸟状态:)
标签: php mysql mysqli prepared-statement