Answer the question
In order to leave comments, you need to log in
How to choose a server when connecting to a database?
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'https://my-site.com/'),
'port' => env('DB_PORT', ''),
'database' => env('DB_DATABASE', 'my_name'),
'username' => env('DB_USERNAME', 'my_name'),
'password' => env('DB_PASSWORD', 'my_pas'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
PDOException in Connector.php line 119:
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
Answer the question
In order to leave comments, you need to log in
laravel.su/docs/5.0/database#read-write-connections
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'https://my-site.com/'),
'port' => env('DB_PORT', ''),
'database' => env('DB_DATABASE', 'my_name'),
'username' => env('DB_USERNAME', 'my_name'),
'password' => env('DB_PASSWORD', 'my_pas'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
'mysql2' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'https://my-site2.com/'),
'port' => env('DB_PORT', ''),
'database' => env('DB_DATABASE', 'my_name2'),
'username' => env('DB_USERNAME', 'my_name3'),
'password' => env('DB_PASSWORD', 'my_pas4'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
DB::connection('mysql')->table('...')->get(); // Выбор из первого соединения
DB::connection('mysql2')->table('...')->get(); // Выбор из второго соединения
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question