I'm using a Laravel 7.3, and one of my requirement is to connect from an Azure Replica Database that includes adding ApplicationIntent = ReadOnly on connection string. But I cant find a way to a customize the connection string generated by laravel to create a PDO Object.
I also tried adding ApplicationIntent = ReadOnly on the database configuration options, but still no luck
'sql_server_readonly' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
'options'=> [
'ApplicationIntent' => 'ReadOnly'
]
],
2条答案
按热度按时间c90pui9n1#
On Laravel 8.0, I needed to set
'readonly' => true
for the ApplicationIntent to be set. See framework code here: https://github.com/illuminate/database/blob/ae346d0a75aa87b83783d44b926d3fcc2d18f430/Connectors/SqlServerConnector.php#L135full config:
wmomyfyw2#
Just add it on the database.php connection config