123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- namespace Doctrine\DBAL\Driver\SQLSrv;
- use Doctrine\DBAL\Driver\AbstractSQLServerDriver;
- use Doctrine\DBAL\Driver\AbstractSQLServerDriver\Exception\PortWithoutHost;
- use Doctrine\Deprecations\Deprecation;
- /**
- * Driver for ext/sqlsrv.
- */
- class Driver extends AbstractSQLServerDriver
- {
- /**
- * {@inheritdoc}
- */
- public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
- {
- $serverName = '';
- if (isset($params['host'])) {
- $serverName = $params['host'];
- if (isset($params['port'])) {
- $serverName .= ',' . $params['port'];
- }
- } elseif (isset($params['port'])) {
- throw PortWithoutHost::new();
- }
- if (isset($params['dbname'])) {
- $driverOptions['Database'] = $params['dbname'];
- }
- if (isset($params['charset'])) {
- $driverOptions['CharacterSet'] = $params['charset'];
- }
- if ($username !== null) {
- $driverOptions['UID'] = $username;
- }
- if ($password !== null) {
- $driverOptions['PWD'] = $password;
- }
- if (! isset($driverOptions['ReturnDatesAsStrings'])) {
- $driverOptions['ReturnDatesAsStrings'] = 1;
- }
- return new Connection($serverName, $driverOptions);
- }
- /**
- * {@inheritdoc}
- *
- * @deprecated
- */
- public function getName()
- {
- Deprecation::trigger(
- 'doctrine/dbal',
- 'https://github.com/doctrine/dbal/issues/3580',
- 'Driver::getName() is deprecated'
- );
- return 'sqlsrv';
- }
- }
|