Home > Back-end >  PDOException in Connection.php line 358: SQLSTATE[HY000]: General error: 1364 Field 'id' d
PDOException in Connection.php line 358: SQLSTATE[HY000]: General error: 1364 Field 'id' d

Time:11-23

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. -Making sure the file permissions are correct (root and apache has permissions to read)

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

Error img:

Update: Whenever I use php artisan migrate:refresh this shows: migrate error

CodePudding user response:

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

You are going to need something like this at the top of your model:

protected $primaryKey = 'video_id';

CodePudding user response:

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.

img

  • Related