refactoring the database layer.
This commit is contained in:
parent
3ada2cbd3e
commit
2521ab3c1d
|
@ -1,7 +1,5 @@
|
|||
<?php namespace Laravel\Database\Connector;
|
||||
|
||||
use Laravel\Database\Connector;
|
||||
|
||||
class Callback extends Connector {
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php namespace Laravel\Database;
|
||||
<?php namespace Laravel\Database\Connector;
|
||||
|
||||
use PDO;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php namespace Laravel\Database\Connector;
|
||||
|
||||
use Laravel\Database\Connector;
|
||||
use PDO;
|
||||
|
||||
class MySQL extends Connector {
|
||||
|
||||
|
@ -24,7 +24,7 @@ public function connect($config)
|
|||
$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']))
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php namespace Laravel\Database\Connector;
|
||||
|
||||
use Laravel\Database\Connector;
|
||||
use PDO;
|
||||
|
||||
class Postgres extends Connector {
|
||||
|
||||
|
@ -19,7 +19,7 @@ public function connect($config)
|
|||
$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']))
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php namespace Laravel\Database\Connector;
|
||||
|
||||
use Laravel\Database\Connector;
|
||||
use PDO;
|
||||
|
||||
class SQLite extends Connector {
|
||||
|
||||
|
@ -14,15 +14,15 @@ public function connect($config)
|
|||
{
|
||||
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'))
|
||||
{
|
||||
return new \PDO('sqlite:'.$path, null, null, $this->options);
|
||||
return new PDO('sqlite:'.$path, null, null, $this->options);
|
||||
}
|
||||
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.");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php namespace Laravel\Database\Query;
|
||||
<?php namespace Laravel\Database\Query\Compiler;
|
||||
|
||||
use Laravel\Database\Query;
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
<?php namespace Laravel\Database\Query\Compiler;
|
||||
|
||||
use Laravel\Database\Connection;
|
||||
use Laravel\Database\Query\Compiler;
|
||||
|
||||
class Factory {
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<?php namespace Laravel\Database\Query\Compiler;
|
||||
|
||||
use Laravel\Database\Query\Compiler;
|
||||
|
||||
class MySQL extends Compiler {
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<?php namespace Laravel\Database\Query\Compiler;
|
||||
|
||||
use Laravel\Database\Query\Compiler;
|
||||
|
||||
class Postgres extends Compiler {
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?php namespace Laravel\Database\Query;
|
||||
|
||||
use Laravel\Database\Query;
|
||||
use Laravel\Database\Connection;
|
||||
|
||||
class Factory {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php namespace Laravel\Database\Query;
|
||||
|
||||
use Laravel\Database\Query;
|
||||
use PDO;
|
||||
|
||||
class Postgres extends Query {
|
||||
|
||||
|
@ -16,7 +16,7 @@ public function insert_get_id($values)
|
|||
|
||||
$query->execute(array_values($values));
|
||||
|
||||
return (int) $query->fetch(\PDO::FETCH_CLASS, 'stdClass')->id;
|
||||
return (int) $query->fetch(PDO::FETCH_CLASS, 'stdClass')->id;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
<?php namespace Laravel\Database;
|
||||
<?php namespace Laravel\Database\Query;
|
||||
|
||||
use Laravel\Database\Connection;
|
||||
|
||||
class Query {
|
||||
|
||||
|
@ -90,12 +92,12 @@ class Query {
|
|||
/**
|
||||
* 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
|
||||
*/
|
||||
public function __construct(Connection $connection, Query\Compiler $compiler, $table)
|
||||
public function __construct(Connection $connection, Compiler\Compiler $compiler, $table)
|
||||
{
|
||||
$this->table = $table;
|
||||
$this->compiler = $compiler;
|
Loading…
Reference in New Issue