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



SQLSTATE[22007]:无效的日期时间格式:1366不正确的整数值:第1行"excercise_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');
});
}

数据库中excercise_type的数据类型必须设置为DATETIME。将其更改为int(11(。该值必须是一个整数,而不是字符串,即Walking。这可能会解决你的问题。

我刚把这个问题问给我哥哥,找到了解决这个问题的办法。首先,我练习的数据类型是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( 首先,在视图中的select标记下为选项指定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( 只需转到您的配置文件夹,创建一个名为constant.php.的文件

3( 现在返回一个数组,写下输入字段的名称,并为它们分配选项字段的值,您在视图端这样写。

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

?>

我希望你能得到帮助。

相关内容

最新更新