sqlstate[22007]:无效的日期时间格式:1366不正确的整数值

ssgvzors  于 2021-06-18  发布在  Mysql
关注(0)|答案(2)|浏览(758)

sqlstate[22007]:无效的日期时间格式:1366不正确的整数值:第1行“exercise\u type”列的“walking”

public function up()
{
    Schema::table('diabetic_records', function (Blueprint $table) {
        $table->unsignedInteger('user_id')->nullable()->after('id');
        $table->decimal('glucose_level',5,2)->nullable()->after('user_id');
        $table->string('glucose_level_time')->nullable()->after('glucose_level');
        $table->string('food_name')->nullable()->after('glucose_level_time');
        $table->integer('food_amount')->nullable()->after('food_name');
        $table->string('treatment')->nullable()->after('food_amount');
        $table->string('medication_name')->nullable()->after('treatment');
        $table->decimal('medication_dose',6,2)->nullable()->after('medication_name');
        $table->string('medication_time')->nullable()->after('medication_dose');
        $table->integer('excercise_type')->nullable()->after('medication_time');
        $table->integer('excercise_duration')->nullable()->after('excercise_type');
    });
}
esyap4oy

esyap4oy1#

我只是通过问我哥哥这个问题找到了解决这个问题的办法。首先,我练习的数据类型是int,我在其中输入字符(字符串)。

$table->integer('excercise_type')->nullable()->after('medication_time');

查看:

<select class="custom-select d-block w-100" name="excercise_type" id="excercise_type" required>
              <option selected="selected" >Walking</option>
              <option >Running</option>
              <option >Cycling</option>
              </select>

在解决错误之前,我键入的代码如下所示
现在让我们开始解决这个错误的一部分
1) 首先,给视图中selecttag下的选项赋值,比如1,2,3。

<select class="custom-select d-block w-100" name="excercise_type" id="excercise_type" required>
              <option selected="selected" value="1">Walking</option>
              <option value="2">Running</option>
              <option value="3">Cycling</option>
              </select>

2) 只需转到config文件夹并创建一个名为constant.php的文件。
3) 现在返回一个数组,写下输入字段的名称,并将选项字段的值赋给它们,您在视图中这样写。

<?php
return[
 'EXERCISE_TYPE_WALKING' => '1',
 'EXERCISE_TYPE_RUNNING' => '2',
' EXERCISE_TYPE_CYCLING' => '3',
];

?>
我希望你能得到帮助。

niwlg2el

niwlg2el2#

的数据类型 excercise_type 在数据库中必须设置为datetime。将其更改为int(11)。并且值必须是整数,而不是字符串,即walking。那也许能解决你的问题。

相关问题