English 中文(简体)
Laravel: default to charset and collation of existing Database?
原标题:

In Laravel, Everytime, while running the website,

"set names utf8 collate utf8_unicode_ci "

is executing.

How can I avoid this ? Instead of doing this in the code. We have configured in the database itself. How can I remove charset and collation in database configuration ?

> config/database.php
> 
>  database  => [
>      driver     =>  mysql ,
>      host       => env( DB_HOST ,  localhost ),
>      port       => env( DB_PORT ),
>      database   => env( DATABASE ),
>      username   => env( DB_USERNAME ,  forge ),
>      password   => env( DB_PASSWORD ,   ),
>      charset    =>  utf8 , // Need to remove or make   
>      collation  =>  utf8_unicode_ci , // Need to remove or make   
>      prefix     => env( DB_PREFIX ,   ),
>      strict     => false, ],
问题回答

You can just remove charset and collation from mysql connection array and run php artisan config:clear after that.

Not directly sure what you try to achieve with this. But it is not possible without changing the MySQL Classes.

Take a look at the Illuminate/Database/Connectors/MySqlConnector Class.





相关问题
Table of calificacions in php and laravel

I created a table in order to show the name of the students, name of the subjects and the grade of the subject of the student I have the next code: this is the index part <form action="{{ ...

How to fix CORS for Capacitor/Quasar App in a Laravel API

I have an App built on top of Quasar and Capacitor, with an API built on top of Laravel. Everything works well on the dev environment until I build and install the app on my phone, then I keep getting ...

Laravel +Vuejs CORS issue

I am facing a dilemma wit the CORS issue. I have application that is configured as follow: API: https://abc.mydomain.com (laravel) front end: https://subdomain.mydomain.com(VueJS) Both applications ...

Laravel wrong redirecting to login page after login

In a multi tenancy with subdomain enviroment (http://zapburger.dex.local) when user fills login form with valid data and make login, laravel redirect to dashboard route (as expected) and then redirect ...

热门标签