Commit 2521ab3c authored by Taylor Otwell's avatar Taylor Otwell

refactoring the database layer.

parent 3ada2cbd
<?php namespace Laravel\Database\Connector; <?php namespace Laravel\Database\Connector;
use Laravel\Database\Connector;
class Callback extends Connector { class Callback extends Connector {
/** /**
......
<?php namespace Laravel\Database; <?php namespace Laravel\Database\Connector;
use PDO; use PDO;
......
<?php namespace Laravel\Database\Connector; <?php namespace Laravel\Database\Connector;
use Laravel\Database\Connector; use PDO;
class MySQL extends Connector { class MySQL extends Connector {
...@@ -24,7 +24,7 @@ class MySQL extends Connector { ...@@ -24,7 +24,7 @@ class MySQL extends Connector {
$dsn .= ';unix_socket='.$config['socket']; $dsn .= ';unix_socket='.$config['socket'];
} }
$connection = new \PDO($dsn, $config['username'], $config['password'], $this->options); $connection = new PDO($dsn, $config['username'], $config['password'], $this->options);
if (isset($config['charset'])) if (isset($config['charset']))
{ {
......
<?php namespace Laravel\Database\Connector; <?php namespace Laravel\Database\Connector;
use Laravel\Database\Connector; use PDO;
class Postgres extends Connector { class Postgres extends Connector {
...@@ -19,7 +19,7 @@ class Postgres extends Connector { ...@@ -19,7 +19,7 @@ class Postgres extends Connector {
$dsn .= ';port='.$config['port']; $dsn .= ';port='.$config['port'];
} }
$connection = new \PDO($dsn, $config['username'], $config['password'], $this->options); $connection = new PDO($dsn, $config['username'], $config['password'], $this->options);
if (isset($config['charset'])) if (isset($config['charset']))
{ {
......
<?php namespace Laravel\Database\Connector; <?php namespace Laravel\Database\Connector;
use Laravel\Database\Connector; use PDO;
class SQLite extends Connector { class SQLite extends Connector {
...@@ -14,15 +14,15 @@ class SQLite extends Connector { ...@@ -14,15 +14,15 @@ class SQLite extends Connector {
{ {
if ($config['database'] == ':memory:') if ($config['database'] == ':memory:')
{ {
return new \PDO('sqlite::memory:', null, null, $this->options); return new PDO('sqlite::memory:', null, null, $this->options);
} }
elseif (file_exists($path = DATABASE_PATH.$config['database'].'.sqlite')) elseif (file_exists($path = DATABASE_PATH.$config['database'].'.sqlite'))
{ {
return new \PDO('sqlite:'.$path, null, null, $this->options); return new PDO('sqlite:'.$path, null, null, $this->options);
} }
elseif (file_exists($config['database'])) elseif (file_exists($config['database']))
{ {
return new \PDO('sqlite:'.$config['database'], null, null, $this->options); return new PDO('sqlite:'.$config['database'], null, null, $this->options);
} }
throw new \Exception("SQLite database [".$config['database']."] could not be found."); throw new \Exception("SQLite database [".$config['database']."] could not be found.");
......
<?php namespace Laravel\Database\Query; <?php namespace Laravel\Database\Query\Compiler;
use Laravel\Database\Query; use Laravel\Database\Query;
......
<?php namespace Laravel\Database\Query\Compiler; <?php namespace Laravel\Database\Query\Compiler;
use Laravel\Database\Connection; use Laravel\Database\Connection;
use Laravel\Database\Query\Compiler;
class Factory { class Factory {
......
<?php namespace Laravel\Database\Query\Compiler; <?php namespace Laravel\Database\Query\Compiler;
use Laravel\Database\Query\Compiler;
class MySQL extends Compiler { class MySQL extends Compiler {
/** /**
......
<?php namespace Laravel\Database\Query\Compiler; <?php namespace Laravel\Database\Query\Compiler;
use Laravel\Database\Query\Compiler;
class Postgres extends Compiler { class Postgres extends Compiler {
/** /**
......
<?php namespace Laravel\Database\Query; <?php namespace Laravel\Database\Query;
use Laravel\Database\Query;
use Laravel\Database\Connection; use Laravel\Database\Connection;
class Factory { class Factory {
......
<?php namespace Laravel\Database\Query; <?php namespace Laravel\Database\Query;
use Laravel\Database\Query; use PDO;
class Postgres extends Query { class Postgres extends Query {
...@@ -16,7 +16,7 @@ class Postgres extends Query { ...@@ -16,7 +16,7 @@ class Postgres extends Query {
$query->execute(array_values($values)); $query->execute(array_values($values));
return (int) $query->fetch(\PDO::FETCH_CLASS, 'stdClass')->id; return (int) $query->fetch(PDO::FETCH_CLASS, 'stdClass')->id;
} }
} }
\ No newline at end of file
<?php namespace Laravel\Database; <?php namespace Laravel\Database\Query;
use Laravel\Database\Connection;
class Query { class Query {
...@@ -90,12 +92,12 @@ class Query { ...@@ -90,12 +92,12 @@ class Query {
/** /**
* Create a new query instance. * Create a new query instance.
* *
* @param Connection $connection * @param Database\Connection $connection
* @param Compiler $compiler * @param Compiler $compiler
* @param string $table * @param string $table
* @return void * @return void
*/ */
public function __construct(Connection $connection, Query\Compiler $compiler, $table) public function __construct(Connection $connection, Compiler\Compiler $compiler, $table)
{ {
$this->table = $table; $this->table = $table;
$this->compiler = $compiler; $this->compiler = $compiler;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment