SqlServerConnector
extends Connector
in package
implements
ConnectorInterface
Interfaces, Classes and Traits
Table of Contents
- $options : array<string|int, mixed>
- The PDO connection options.
- connect() : PDO
- Establish a database connection.
- createConnection() : PDO
- Create a new PDO connection.
- getDefaultOptions() : array<string|int, mixed>
- Get the default PDO connection options.
- getOptions() : array<string|int, mixed>
- Get the PDO options based on the configuration.
- setDefaultOptions() : void
- Set the default PDO connection options.
- buildConnectString() : string
- Build a connection string from the given arguments.
- buildHostString() : string
- Build a host string from the given configuration.
- causedByLostConnection() : bool
- Determine if the given exception was caused by a lost connection.
- createPdoConnection() : PDO
- Create a new PDO connection instance.
- getAvailableDrivers() : array<string|int, mixed>
- Get the available PDO drivers.
- getDblibDsn() : string
- Get the DSN string for a DbLib connection.
- getDsn() : string
- Create a DSN string from a configuration.
- getOdbcDsn() : string
- Get the DSN string for an ODBC connection.
- getSqlSrvDsn() : string
- Get the DSN string for a SqlSrv connection.
- isPersistentConnection() : bool
- Determine if the connection is persistent.
- prefersOdbc() : bool
- Determine if the database configuration prefers ODBC.
- tryAgainIfCausedByLostConnection() : PDO
- Handle an exception that occurred during connect execution.
Properties
$options
The PDO connection options.
protected
array<string|int, mixed>
$options
= [PDO::ATTR_CASE => PDO::CASE_NATURAL, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL, PDO::ATTR_STRINGIFY_FETCHES => false]
Methods
connect()
Establish a database connection.
public
connect(array<string|int, mixed> $config) : PDO
Parameters
- $config : array<string|int, mixed>
Return values
PDO —createConnection()
Create a new PDO connection.
public
createConnection(string $dsn, array<string|int, mixed> $config, array<string|int, mixed> $options) : PDO
Parameters
- $dsn : string
- $config : array<string|int, mixed>
- $options : array<string|int, mixed>
Return values
PDO —getDefaultOptions()
Get the default PDO connection options.
public
getDefaultOptions() : array<string|int, mixed>
Return values
array<string|int, mixed> —getOptions()
Get the PDO options based on the configuration.
public
getOptions(array<string|int, mixed> $config) : array<string|int, mixed>
Parameters
- $config : array<string|int, mixed>
Return values
array<string|int, mixed> —setDefaultOptions()
Set the default PDO connection options.
public
setDefaultOptions(array<string|int, mixed> $options) : void
Parameters
- $options : array<string|int, mixed>
Return values
void —buildConnectString()
Build a connection string from the given arguments.
protected
buildConnectString(string $driver, array<string|int, mixed> $arguments) : string
Parameters
- $driver : string
- $arguments : array<string|int, mixed>
Return values
string —buildHostString()
Build a host string from the given configuration.
protected
buildHostString(array<string|int, mixed> $config, string $separator) : string
Parameters
- $config : array<string|int, mixed>
- $separator : string
Return values
string —causedByLostConnection()
Determine if the given exception was caused by a lost connection.
protected
causedByLostConnection(Exception $e) : bool
Parameters
- $e : Exception
Return values
bool —createPdoConnection()
Create a new PDO connection instance.
protected
createPdoConnection(string $dsn, string $username, string $password, array<string|int, mixed> $options) : PDO
Parameters
- $dsn : string
- $username : string
- $password : string
- $options : array<string|int, mixed>
Return values
PDO —getAvailableDrivers()
Get the available PDO drivers.
protected
getAvailableDrivers() : array<string|int, mixed>
Return values
array<string|int, mixed> —getDblibDsn()
Get the DSN string for a DbLib connection.
protected
getDblibDsn(array<string|int, mixed> $config) : string
Parameters
- $config : array<string|int, mixed>
Return values
string —getDsn()
Create a DSN string from a configuration.
protected
getDsn(array<string|int, mixed> $config) : string
Parameters
- $config : array<string|int, mixed>
Return values
string —getOdbcDsn()
Get the DSN string for an ODBC connection.
protected
getOdbcDsn(array<string|int, mixed> $config) : string
Parameters
- $config : array<string|int, mixed>
Return values
string —getSqlSrvDsn()
Get the DSN string for a SqlSrv connection.
protected
getSqlSrvDsn(array<string|int, mixed> $config) : string
Parameters
- $config : array<string|int, mixed>
Return values
string —isPersistentConnection()
Determine if the connection is persistent.
protected
isPersistentConnection(array<string|int, mixed> $options) : bool
Parameters
- $options : array<string|int, mixed>
Return values
bool —prefersOdbc()
Determine if the database configuration prefers ODBC.
protected
prefersOdbc(array<string|int, mixed> $config) : bool
Parameters
- $config : array<string|int, mixed>
Return values
bool —tryAgainIfCausedByLostConnection()
Handle an exception that occurred during connect execution.
protected
tryAgainIfCausedByLostConnection(Exception $e, string $dsn, string $username, string $password, array<string|int, mixed> $options) : PDO
Parameters
- $e : Exception
- $dsn : string
- $username : string
- $password : string
- $options : array<string|int, mixed>