Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sqlsrv
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
sqlsrv
Commits
df3928ed
Commit
df3928ed
authored
1 year ago
by
Phil Stewart
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3291464
by pstewart: Support for SQL Server specific DSN connection options
parent
26504dca
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!80
Issue #3291464: Support for SQL Server specific DSN connection options
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Driver/Database/sqlsrv/Connection.php
+54
-0
54 additions, 0 deletions
src/Driver/Database/sqlsrv/Connection.php
with
54 additions
and
0 deletions
src/Driver/Database/sqlsrv/Connection.php
+
54
−
0
View file @
df3928ed
...
@@ -325,6 +325,7 @@ class Connection extends DatabaseConnection {
...
@@ -325,6 +325,7 @@ class Connection extends DatabaseConnection {
// Build the DSN.
// Build the DSN.
$options
=
[];
$options
=
[];
$options
[
'Server'
]
=
$connection_options
[
'host'
]
.
(
!
empty
(
$connection_options
[
'port'
])
?
','
.
$connection_options
[
'port'
]
:
''
);
$options
[
'Server'
]
=
$connection_options
[
'host'
]
.
(
!
empty
(
$connection_options
[
'port'
])
?
','
.
$connection_options
[
'port'
]
:
''
);
// We might not have a database in the
// We might not have a database in the
// connection options, for example, during
// connection options, for example, during
// database creation in Install.
// database creation in Install.
...
@@ -332,6 +333,59 @@ class Connection extends DatabaseConnection {
...
@@ -332,6 +333,59 @@ class Connection extends DatabaseConnection {
$options
[
'Database'
]
=
$connection_options
[
'database'
];
$options
[
'Database'
]
=
$connection_options
[
'database'
];
}
}
// Set sqlsrv specific DSN options.
if
(
isset
(
$connection_options
[
'readonly'
]))
{
$options
[
'ApplicationIntent'
]
=
'ReadOnly'
;
}
if
(
isset
(
$connection_options
[
'pooling'
])
&&
$connection_options
[
'pooling'
]
===
false
)
{
$options
[
'ConnectionPooling'
]
=
'0'
;
}
if
(
isset
(
$connection_options
[
'appname'
]))
{
$options
[
'APP'
]
=
$connection_options
[
'appname'
];
}
if
(
isset
(
$connection_options
[
'encrypt'
]))
{
$options
[
'Encrypt'
]
=
$connection_options
[
'encrypt'
];
}
if
(
isset
(
$connection_options
[
'trust_server_certificate'
]))
{
$options
[
'TrustServerCertificate'
]
=
$connection_options
[
'trust_server_certificate'
];
}
if
(
isset
(
$connection_options
[
'multiple_active_result_sets'
])
&&
$connection_options
[
'multiple_active_result_sets'
]
===
false
)
{
$options
[
'MultipleActiveResultSets'
]
=
'false'
;
}
if
(
isset
(
$connection_options
[
'transaction_isolation'
]))
{
$options
[
'TransactionIsolation'
]
=
$connection_options
[
'transaction_isolation'
];
}
if
(
isset
(
$connection_options
[
'multi_subnet_failover'
]))
{
$options
[
'MultiSubnetFailover'
]
=
$connection_options
[
'multi_subnet_failover'
];
}
if
(
isset
(
$connection_options
[
'column_encryption'
]))
{
$options
[
'ColumnEncryption'
]
=
$connection_options
[
'column_encryption'
];
}
if
(
isset
(
$connection_options
[
'key_store_authentication'
]))
{
$options
[
'KeyStoreAuthentication'
]
=
$connection_options
[
'key_store_authentication'
];
}
if
(
isset
(
$connection_options
[
'key_store_principal_id'
]))
{
$options
[
'KeyStorePrincipalId'
]
=
$connection_options
[
'key_store_principal_id'
];
}
if
(
isset
(
$connection_options
[
'key_store_secret'
]))
{
$options
[
'KeyStoreSecret'
]
=
$connection_options
[
'key_store_secret'
];
}
if
(
isset
(
$connection_options
[
'login_timeout'
]))
{
$options
[
'LoginTimeout'
]
=
$connection_options
[
'login_timeout'
];
}
// Build the DSN.
// Build the DSN.
$dsn
=
'sqlsrv:'
;
$dsn
=
'sqlsrv:'
;
foreach
(
$options
as
$key
=>
$value
)
{
foreach
(
$options
as
$key
=>
$value
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment