database refactoring for dependency injection and other general refactoring.

This commit is contained in:
Taylor Otwell
2011-09-04 21:45:37 -05:00
parent c2f5e7eeb5
commit 3e874867b8
5 changed files with 30 additions and 18 deletions

View File

@@ -40,15 +40,19 @@ class Connection {
/**
* Create a new Connection instance.
*
* @param string $name
* @param array $config
* @param Connector $connector
* @param Connector $connector
* @param Query\Factory $factory
* @param Compiler\Factory $compiler
* @param string $name
* @param array $config
* @return void
*/
public function __construct($name, $config, Connector $connector)
public function __construct(Connector $connector, Query\Factory $query, Query\Compiler\Factory $compiler, $name, $config)
{
$this->name = $name;
$this->query = $query;
$this->config = $config;
$this->compiler = $compiler;
$this->connector = $connector;
}
@@ -152,7 +156,7 @@ class Connection {
*/
public function table($table)
{
return Query\Factory::make($table, $this, Query\Compiler\Factory::make($this));
return $this->query->make($this, $this->compiler->make($this), $table);
}
/**
@@ -167,4 +171,12 @@ class Connection {
return $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME);
}
/**
* Magic Method for dynamically beginning queries on database tables.
*/
public function __call($method, $parameters)
{
return $this->table($method);
}
}