Driver.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace Doctrine\DBAL\Driver\PDOIbm;
  3. use Doctrine\DBAL\Driver\AbstractDB2Driver;
  4. use Doctrine\DBAL\Driver\PDO\Connection;
  5. use Doctrine\Deprecations\Deprecation;
  6. /**
  7. * Driver for the PDO IBM extension.
  8. *
  9. * @deprecated Use the driver based on the ibm_db2 extension instead.
  10. */
  11. class Driver extends AbstractDB2Driver
  12. {
  13. /**
  14. * {@inheritdoc}
  15. */
  16. public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
  17. {
  18. return new Connection(
  19. $this->_constructPdoDsn($params),
  20. $username,
  21. $password,
  22. $driverOptions
  23. );
  24. }
  25. /**
  26. * Constructs the IBM PDO DSN.
  27. *
  28. * @param mixed[] $params
  29. *
  30. * @return string The DSN.
  31. */
  32. private function _constructPdoDsn(array $params)
  33. {
  34. $dsn = 'ibm:';
  35. if (isset($params['host'])) {
  36. $dsn .= 'HOSTNAME=' . $params['host'] . ';';
  37. }
  38. if (isset($params['port'])) {
  39. $dsn .= 'PORT=' . $params['port'] . ';';
  40. }
  41. $dsn .= 'PROTOCOL=TCPIP;';
  42. if (isset($params['dbname'])) {
  43. $dsn .= 'DATABASE=' . $params['dbname'] . ';';
  44. }
  45. return $dsn;
  46. }
  47. /**
  48. * {@inheritdoc}
  49. *
  50. * @deprecated
  51. */
  52. public function getName()
  53. {
  54. Deprecation::trigger(
  55. 'doctrine/dbal',
  56. 'https://github.com/doctrine/dbal/issues/3580',
  57. 'Driver::getName() is deprecated'
  58. );
  59. return 'pdo_ibm';
  60. }
  61. }