Browse Source

refactoring the database layer.

Taylor Otwell 13 years ago
parent
commit
2521ab3c1d

+ 0 - 2
laravel/database/connector/callback.php

@@ -1,7 +1,5 @@
 <?php namespace Laravel\Database\Connector;
 <?php namespace Laravel\Database\Connector;
 
 
-use Laravel\Database\Connector;
-
 class Callback extends Connector {
 class Callback extends Connector {
 
 
 	/**
 	/**

+ 1 - 1
laravel/database/connector.php → laravel/database/connector/connector.php

@@ -1,4 +1,4 @@
-<?php namespace Laravel\Database;
+<?php namespace Laravel\Database\Connector;
 
 
 use PDO;
 use PDO;
 
 

+ 2 - 2
laravel/database/connector/mysql.php

@@ -1,6 +1,6 @@
 <?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 {
 			$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']))
 		{
 		{

+ 2 - 2
laravel/database/connector/postgres.php

@@ -1,6 +1,6 @@
 <?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 {
 			$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']))
 		{
 		{

+ 4 - 4
laravel/database/connector/sqlite.php

@@ -1,6 +1,6 @@
 <?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 {
 	{
 	{
 		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.");

+ 1 - 1
laravel/database/query/compiler.php → laravel/database/query/compiler/compiler.php

@@ -1,4 +1,4 @@
-<?php namespace Laravel\Database\Query;
+<?php namespace Laravel\Database\Query\Compiler;
 
 
 use Laravel\Database\Query;
 use Laravel\Database\Query;
 
 

+ 0 - 1
laravel/database/query/compiler/factory.php

@@ -1,7 +1,6 @@
 <?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 {
 
 

+ 0 - 2
laravel/database/query/compiler/mysql.php

@@ -1,7 +1,5 @@
 <?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 {
 
 
 	/**
 	/**

+ 0 - 2
laravel/database/query/compiler/postgres.php

@@ -1,7 +1,5 @@
 <?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 {
 
 
 	/**
 	/**

+ 0 - 1
laravel/database/query/factory.php

@@ -1,6 +1,5 @@
 <?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 {

+ 2 - 2
laravel/database/query/postgres.php

@@ -1,6 +1,6 @@
 <?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 {
 
 
 		$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;
 	}
 	}
 
 
 }
 }

+ 7 - 5
laravel/database/query.php → laravel/database/query/query.php

@@ -1,4 +1,6 @@
-<?php namespace Laravel\Database;
+<?php namespace Laravel\Database\Query;
+
+use Laravel\Database\Connection;
 
 
 class Query {
 class Query {
 
 
@@ -90,12 +92,12 @@ class Query {
 	/**
 	/**
 	 * Create a new query instance.
 	 * Create a new query instance.
 	 *
 	 *
-	 * @param  Connection  $connection
-	 * @param  Compiler    $compiler
-	 * @param  string      $table
+	 * @param  Database\Connection  $connection
+	 * @param  Compiler             $compiler
+	 * @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;