mysql - 如何防止页面刷新时数据库中的自动增量?拉拉维尔 7
问题描述
我有一些条件(如下所示)在数据库表('quizzes')的列('pass_number')中将值增加 1:
“测验”:
Schema::create('quizzes', function (Blueprint $table) {
$table->id();
$table->string('qname');
$table->text('description');
$table->text('subcategory');
$table->text('by');
$table->text('by_username');
$table->text('profileUrl');
$table->integer('minutes');
$table->integer('cutoff');
$table->integer('pass_number')->default(0)->nullable();
$table->timestamps();
});
健康)状况:
$cutoff1 = DB::table('quizzes')
->where('id', '=', $quizId)
->value('cutoff');
if ($percentage > $cutoff1) {
DB::table('quizzes')
->where('id', $quizId)
->update([
'pass_number' => DB::raw('pass_number + 1')
]);
}
我可以在“pass_number”中增加,但在页面刷新时我想停止它。
*$percentage 我从用户在特定测验中的表现中获得。
解决方案
推荐阅读
- python - VS Code - Python 模块未加载,如何安装或发生了什么
- swift - UINavigationController 中的标题不正确
- firebase - 使用 firebase 和 flutter 登录 google 后获取用户详细信息
- javascript - 将从 Javascript 发送的列表映射到 Java 后端
- r - R中的数据转换 - 傻瓜
- php - 按特定键过滤多维数组并创建子数组PHP?
- c++ - INT 如何在 C++ 中返回为 INT&?
- swift - 重建失败 HelloPhotogrammetry 错误
- javascript - 如何解决javascript中的模板文字问题?
- sql - Oracle:从结果集 ID 生成 WHERE 子句?