Driver.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace Doctrine\DBAL\Driver\PDOOracle;
  3. use Doctrine\DBAL\Driver\AbstractOracleDriver;
  4. use Doctrine\DBAL\Driver\PDO;
  5. use Doctrine\DBAL\Exception;
  6. use Doctrine\Deprecations\Deprecation;
  7. use PDOException;
  8. /**
  9. * PDO Oracle driver.
  10. *
  11. * @deprecated Use {@link PDO\OCI\Driver} instead.
  12. */
  13. class Driver extends AbstractOracleDriver
  14. {
  15. /**
  16. * {@inheritdoc}
  17. */
  18. public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
  19. {
  20. try {
  21. return new PDO\Connection(
  22. $this->constructPdoDsn($params),
  23. $username,
  24. $password,
  25. $driverOptions
  26. );
  27. } catch (PDOException $e) {
  28. throw Exception::driverException($this, $e);
  29. }
  30. }
  31. /**
  32. * Constructs the Oracle PDO DSN.
  33. *
  34. * @param mixed[] $params
  35. *
  36. * @return string The DSN.
  37. */
  38. private function constructPdoDsn(array $params)
  39. {
  40. $dsn = 'oci:dbname=' . $this->getEasyConnectString($params);
  41. if (isset($params['charset'])) {
  42. $dsn .= ';charset=' . $params['charset'];
  43. }
  44. return $dsn;
  45. }
  46. /**
  47. * {@inheritdoc}
  48. */
  49. public function getName()
  50. {
  51. Deprecation::trigger(
  52. 'doctrine/dbal',
  53. 'https://github.com/doctrine/dbal/issues/3580',
  54. 'Driver::getName() is deprecated'
  55. );
  56. return 'pdo_oracle';
  57. }
  58. }