added database connectors and cleaned up configuration.

This commit is contained in:
Taylor Otwell
2011-09-17 23:46:24 -05:00
parent 5387312e0d
commit cb5a426cba
8 changed files with 244 additions and 23 deletions

View File

@@ -0,0 +1,41 @@
<?php namespace Laravel\Database\Connectors; use PDO;
abstract class Connector {
/**
* The PDO connection options.
*
* @var array
*/
protected $options = array(
PDO::ATTR_CASE => PDO::CASE_LOWER,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL,
PDO::ATTR_STRINGIFY_FETCHES => false,
PDO::ATTR_EMULATE_PREPARES => false,
);
/**
* Establish a PDO database connection for a given database configuration.
*
* @param array $config
* @return PDO
*/
abstract public function connect($config);
/**
* Get the PDO connection options for a given database configuration.
*
* Developer specified options will override the default connection options.
*
* @param array $config
* @return array
*/
protected function options($config)
{
$options = (isset($config['options'])) ? $config['options'] : array();
return array_merge($this->options, $options);
}
}