Driver.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Doctrine\DBAL\Driver\OCI8;
  3. use Doctrine\DBAL\DBALException;
  4. use Doctrine\DBAL\Driver\AbstractOracleDriver;
  5. use const OCI_DEFAULT;
  6. /**
  7. * A Doctrine DBAL driver for the Oracle OCI8 PHP extensions.
  8. */
  9. class Driver extends AbstractOracleDriver
  10. {
  11. /**
  12. * {@inheritdoc}
  13. */
  14. public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
  15. {
  16. try {
  17. return new OCI8Connection(
  18. $username,
  19. $password,
  20. $this->_constructDsn($params),
  21. $params['charset'] ?? null,
  22. $params['sessionMode'] ?? OCI_DEFAULT,
  23. $params['persistent'] ?? false
  24. );
  25. } catch (OCI8Exception $e) {
  26. throw DBALException::driverException($this, $e);
  27. }
  28. }
  29. /**
  30. * Constructs the Oracle DSN.
  31. *
  32. * @param mixed[] $params
  33. *
  34. * @return string The DSN.
  35. */
  36. protected function _constructDsn(array $params)
  37. {
  38. return $this->getEasyConnectString($params);
  39. }
  40. /**
  41. * {@inheritdoc}
  42. */
  43. public function getName()
  44. {
  45. return 'oci8';
  46. }
  47. }