我在mysql中遇到了问题: 我的PHP与MySQL断开连接以进行简单查询。错误是:
查询期间与MySQL服务器的连接丢失。
它被抛出:
$stmt->execute();
$app->post('/checkmd5', function() use($app) {
$data = $app->request()->params();
$version = $data["VERSION"];
$md5 = $data["MD5"];
$stmt = getDb()->prepare("SELECT MD5 FROM UpdateInfo WHERE VersionName = ?");
$stmt->bind_param("s", $version);
$stmt->execute();
$stmt->store_result();
if ($stmt->num_rows() > 0) {
$stmt->bind_result($dbMD5);
$stmt->fetch();
if ($md5 == $dbMD5)
{
$app->render(200, array("SUCCESS_MD5_MATCH", "VALID" => "true"));
}
else
{
$app->render(400, array("msg" => "ERROR_NO_MD5_MATCH", "VALID" => "false"));
}
}
else
{
$app->render(400, array("msg" => "ERROR_VERSION_STRING_NOT_FOUND", "VALID" => "false", "VERSION" => $version));
}
});
答案 0 :(得分:0)
只需将getDb()的返回值保存到变量
即可解决问题