connector.php 950 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php namespace Laravel\Database\Connectors; use PDO;
  2. abstract class Connector {
  3. /**
  4. * The PDO connection options.
  5. *
  6. * @var array
  7. */
  8. protected $options = array(
  9. PDO::ATTR_CASE => PDO::CASE_LOWER,
  10. PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
  11. PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL,
  12. PDO::ATTR_STRINGIFY_FETCHES => false,
  13. PDO::ATTR_EMULATE_PREPARES => false,
  14. );
  15. /**
  16. * Establish a PDO database connection for a given database configuration.
  17. *
  18. * @param array $config
  19. * @return PDO
  20. */
  21. abstract public function connect($config);
  22. /**
  23. * Get the PDO connection options for a given database configuration.
  24. *
  25. * Developer specified options will override the default connection options.
  26. *
  27. * @param array $config
  28. * @return array
  29. */
  30. protected function options($config)
  31. {
  32. $options = (isset($config['options'])) ? $config['options'] : array();
  33. return array_merge($this->options, $options);
  34. }
  35. }