refactoring the database layer.

This commit is contained in:
Taylor Otwell
2011-09-12 21:48:48 -05:00
parent b8a901c792
commit 045858d88d
6 changed files with 73 additions and 111 deletions

View File

@@ -1,34 +0,0 @@
<?php namespace Laravel\Database\Query\Compiler;
use Laravel\Database\Connection;
class Factory {
/**
* Create a new query compiler for a given connection.
*
* Using driver-based compilers allows us to provide the proper syntax to different database
* systems using a common API. A core set of functions is provided through the base Compiler
* class, which can be extended and overridden for various database systems.
*
* @param Connection $connection
* @return Compiler
*/
public static function make(Connection $connection)
{
$compiler = (isset($connection->config['compiler'])) ? $connection->config['compiler'] : $connection->driver();
switch ($compiler)
{
case 'mysql':
return new MySQL;
case 'pgsql':
return new Postgres;
default:
return new Compiler;
}
}
}

View File

@@ -1,27 +0,0 @@
<?php namespace Laravel\Database\Query;
use Laravel\Database\Connection;
class Factory {
/**
* Create a new query instance based on the connection driver.
*
* @param Connection $connection
* @param Compiler $compiler
* @param string $table
* @return Query
*/
public function make(Connection $connection, Compiler $compiler, $table)
{
switch ($connection->driver())
{
case 'pgsql':
return new Postgres($connection, $compiler, $table);
default:
return new Query($connection, $compiler, $table);
}
}
}

View File

@@ -7,14 +7,14 @@ class Query {
/**
* The database connection.
*
* @var Connection
* @var Database\Connection
*/
public $connection;
/**
* The query compiler instance.
*
* @var Compiler
* @var Compiler\Compiler
*/
public $compiler;
@@ -93,7 +93,7 @@ class Query {
* Create a new query instance.
*
* @param Database\Connection $connection
* @param Compiler $compiler
* @param Compiler\Compiler $compiler
* @param string $table
* @return void
*/