Files
spa-api/laravel/database/connector/factory.php

30 lines
555 B
PHP
Raw Normal View History

2011-08-25 23:12:30 -05:00
<?php namespace Laravel\Database\Connector;
2011-08-19 20:12:39 -05:00
class Factory {
/**
* Create a new database connector instance for a given driver.
*
2011-08-19 21:18:59 -05:00
* @param array $config
2011-08-19 20:12:39 -05:00
* @return Connector
*/
2011-08-19 21:18:59 -05:00
public static function make($config)
2011-08-19 20:12:39 -05:00
{
2011-08-19 21:18:59 -05:00
if (isset($config['connector'])) return new Callback;
switch ($config['driver'])
2011-08-19 20:12:39 -05:00
{
case 'sqlite':
return new SQLite;
case 'mysql':
return new MySQL;
2011-08-19 21:18:59 -05:00
case 'pgsql':
2011-08-19 20:12:39 -05:00
return new Postgres;
}
2011-08-19 21:18:59 -05:00
throw new \Exception("Database configuration is invalid. Please verify your configuration.");
2011-08-19 20:12:39 -05:00
}
}