|
@@ -12,6 +12,13 @@ class Database {
|
|
|
*/
|
|
|
public static $connections = array();
|
|
|
|
|
|
+ /**
|
|
|
+ * The third-party driver registrar.
|
|
|
+ *
|
|
|
+ * @var array
|
|
|
+ */
|
|
|
+ public static $registrar = array();
|
|
|
+
|
|
|
/**
|
|
|
* Get a database connection.
|
|
|
*
|
|
@@ -66,6 +73,11 @@ class Database {
|
|
|
*/
|
|
|
protected static function connector($driver)
|
|
|
{
|
|
|
+ if (isset(static::$registrar[$driver]))
|
|
|
+ {
|
|
|
+ return static::$registrar[$driver]['connector']();
|
|
|
+ }
|
|
|
+
|
|
|
switch ($driver)
|
|
|
{
|
|
|
case 'sqlite':
|
|
@@ -120,6 +132,22 @@ class Database {
|
|
|
return Database\Connection::$queries;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Register a database connector and grammars.
|
|
|
+ *
|
|
|
+ * @param string $name
|
|
|
+ * @param Closure $connector
|
|
|
+ * @param Closure $query
|
|
|
+ * @param Closure $schema
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public static function register($name, Closure $connector, $query = null, $schema = null)
|
|
|
+ {
|
|
|
+ if (is_null($query)) $query = '\Laravel\Database\Query\Grammars\Grammar';
|
|
|
+
|
|
|
+ static::$registrar[$name] = compact('connector', 'query', 'schema');
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Magic Method for calling methods on the default database connection.
|
|
|
*
|