以下有问题的代码始终记录affected_rows 为0。我检查了我的数据库,每次都可以正常更新行。为什么是0?
public static function updateNextRunTime($nextRunTime)
{
$mysqli = new mysqli(GDB_HOST, GDB_USERNAME, GDB_PASSWORD, GDB_NAME);
if ($mysqli->connect_errno)
{
throw new Exception('DB Connection Failed. Error Code: ' . $mysqli->connect_errno);
}
$cmd = $mysqli->prepare("UPDATE balanceagent SET NextRunTime = ? WHERE Id = 1");
if (!$cmd)
{
throw new Exception($mysqli->error);
}
$cmd->bind_param('s', $nextRunTime);
$cmd->execute();
$rows = $mysqli->affected_rows;
$cmd->close();
$mysqli->close();
if ($rows != 1)
{
logToFile("Balance Agent Error - Failed to update the next run time! - Affected rows: " . $rows);
}
}