Driver.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace Doctrine\DBAL\Driver\OCI8;
  3. use Doctrine\DBAL\Driver\AbstractOracleDriver;
  4. use Doctrine\DBAL\Exception;
  5. use const OCI_NO_AUTO_COMMIT;
  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 Connection(
  18. (string) $username,
  19. (string) $password,
  20. $this->_constructDsn($params),
  21. $params['charset'] ?? '',
  22. $params['sessionMode'] ?? OCI_NO_AUTO_COMMIT,
  23. $params['persistent'] ?? false
  24. );
  25. } catch (OCI8Exception $e) {
  26. throw Exception::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. * @deprecated
  44. */
  45. public function getName()
  46. {
  47. return 'oci8';
  48. }
  49. }