[英]PDOException in Connection.php line 358: SQLSTATE[HY000]: General error: 1364 Field 'id' doesn't have a default value
I have tried so many different ways to solve this problem but nothing seems to be working.我尝试了很多不同的方法来解决这个问题,但似乎没有任何效果。 How do I fix it?我如何解决它? I tried: -setting auto increment for table.我试过: - 设置表的自动增量。 -reinstalling php laravel, re-installing and checking all the configuration of PHP -Clearning php artisan cache, config.. etc -Refreshing php artisan. -reinstalling php laravel, re-installing and checking all the configuration of PHP -Clearning php artisan cache, config.. etc -Refreshing php artisan. -Making sure the file permissions are correct (root and apache has permissions to read) -确保文件权限正确(root和apache有读取权限)
Let me know if I need to include anything else neccessary.让我知道是否需要包括其他任何必要的内容。 Thanks in advance.提前致谢。
my env:我的环境:
APP_NAME=Laravel
APP_ENV=local
APP_KEY=66ixWFPHjUmrFykF3mBw2nfpFPiqLGGe
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=daily
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=streaming_new
DB_USERNAME=myuser
DB_PASSWORD=mypassword
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
Connection.php file: enter link description here Connection.php 文件:在此处输入链接描述
Update: Whenever I use php artisan migrate:refresh
this shows: migrate error更新:每当我使用php artisan migrate:refresh
这显示:迁移错误
I'm going to make a guess from the error and say that you need to set your primary key in your model to be 'video_id'.我将从错误中进行猜测,并说您需要将 model 中的主键设置为“video_id”。 Laravel presumes all model ID's to be 'id', hence the error message mentioning 'id', but it looks like you are using 'video_id' as your model ID. Laravel 假定所有 model ID 都是“id”,因此错误消息提到“id”,但看起来您正在使用“video_id”作为 Z20F35E630DAF44DFA4C3F68F539。
You are going to need something like this at the top of your model:您将在 model 的顶部需要这样的东西:
protected $primaryKey = 'video_id';
Thank you everyone, it worked I had an issue with the migration, I had few errors using the php artisan migrate
and I thought it was working, then I had to add few missing modules and used the same command then it worked.谢谢大家,它成功了我在迁移时遇到了问题,使用php artisan migrate
时我遇到了一些错误,我认为它可以正常工作,然后我不得不添加一些缺少的模块并使用相同的命令然后它就可以工作了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.