简体   繁体   English

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

[英]SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value

SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'Walking' for column 'excercise_type' at row 1 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');
    });
}

The data type of excercise_type in database must have been set to DATETIME. 数据库中excercise_type的数据类型必须已设置为DATETIME。 Change it to int(11). 将其更改为int(11)。 And the value must be a integer, not string ie Walking. 并且该值必须是整数,而不是字符串,即Walking。 That might solve your problem. 那可能会解决您的问题。

I just found the solution of this problem by asking this problem to my elder brother. 通过向我的哥哥问这个问题,我找到了解决这个问题的方法。 first of all my data type of exercise is int and i am putting characters(string) in it. 首先,我的运动数据类型是int,我将character(string)放入其中。

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

view: 视图:

<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>

before error resolving the code look like this which i typed 错误解决代码之前的错误看起来像我键入

now lets start resolving part of this error 现在让我们开始解决部分错误

1)First of all give values like 1,2,3 to your options under select tag in your view . 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) just go to your config folder and create a file with the name of constant.php . 2)只需转到您的config文件夹并创建一个名为constant.php的文件。

3) now return an array and write the name of your input field and assign them values of your option field which your write in your view side like this . 3)现在返回一个数组,并输入您的输入字段的名称,并为它们分配选项字段的值,您可以像这样在视图侧写入。

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

?> ?>

i hope you will get help by this. 我希望你能从中得到帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SQLSTATE [22007]:无效的日期时间格式:1366 不正确的 integer 值:问题 - SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: problem Laravel 8:SQLSTATE[22007]:无效的日期时间格式:1366 不正确的 integer 值 - Laravel 8: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value SQLSTATE [22007]:无效的日期时间格式:1366错误的整数值:行1的列&#39;infraction_id&#39;的&#39;[“ 1”,“ 3”,“ 66”,“ 68”]&#39; - SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: '[“1”,“3”,“66”,“68”]' for column 'infraction_id' at row 1 SQLSTATE[22007]:无效的日期时间格式:1366 不正确的整数值:Laravel 中的“column_name” - SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'column_name' in Laravel SQLSTATE [22007]:无效的日期时间格式:1366 不正确的 integer 值:“isVisible”列的“true” - SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'true' for column 'isVisible' QLSTATE [22007]:无效的日期时间格式:1366 不正确的 integer 值 laravel - QLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value laravel SQLSTATE[22007]:无效的日期时间格式:1366 字符串值不正确,html_entity_decode function - SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect string value, html_entity_decode function laravel SQLSTATE [22007]:无效的日期时间格式:1366不正确的十进制值:&#39;buy_amt * 0.00097812555575316&#39;为行1上的价格列错误 - laravel SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect decimal value: 'buy_amt * 0.00097812555575316' for column 'price' at row 1 error SQLSTATE[22007]:无效的日期时间格式:1292 日期时间值不正确 - SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value 无效的日期时间格式:1366不正确的整数值: - Invalid datetime format: 1366 Incorrect integer value:
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM