Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to configure MARS on SqlServer Connections #20113

Merged
merged 1 commit into from
Jul 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Illuminate/Database/Connectors/SqlServerConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ protected function getSqlSrvDsn(array $config)
$arguments['TrustServerCertificate'] = $config['trust_server_certificate'];
}

if (isset($config['multiple_active_resultsets']) && $config['multiple_active_resultsets'] === false) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$arguments['MultipleActiveResultSets'] = $config['multiple_active_resultsets'] ?? true;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for your observation, Laravel 5.4 still supports PHP 5.6 which does not have the null coalesce operator, so, unfortunately that cannot be used. I hope it gets merged on Laravel 5.4 because that is what I use in production.

Also the argument should only be set to the string value 'false' (not the false boolean value) only when explicitly disabled, because:

  1. MARS is enabled by default (see the Microsoft docs linked above)
  2. The buildConnectString(...) method uses sprintf so a false boolean value would be outputted as the string '0', and if you look in Microsoft documentation linked above the added option to the connectiion string should be MultipleActiveResultSets=false
  3. I used the $config['pooling'] (a few lines above) as an example on how to do it.

$arguments['MultipleActiveResultSets'] = 'false';
}

return $this->buildConnectString('sqlsrv', $arguments);
}

Expand Down