'mysql' => [
'driver' => 'mysql',
'read' => [
'host' => '127.0.0.1',
'database' => 'laravels',
],
'write' => [
'host' => '127.0.0.1',
'database' => 'laravel',
],
'url' => env('DATABASE_URL'),
// 'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
// 'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
配置文件进行配置好了 , 并且read的数据库也有数据
但是在调用方法进行查询的时候 报错
$a = DB::connection('read')->table('users')->get();
这是为啥?
谢谢!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…