Commit 9d4d6e52 authored by Taylor Otwell's avatar Taylor Otwell

refactor database structure... moved db\manager back to system\db.php

parent 21a6040a
......@@ -26,7 +26,7 @@ return array(
'Cookie' => 'System\\Cookie',
'Crypt' => 'System\\Crypt',
'Date' => 'System\\Date',
'DB' => 'System\\DB\\Manager',
'DB' => 'System\\DB',
'Eloquent' => 'System\\DB\\Eloquent\\Model',
'File' => 'System\\File',
'Form' => 'System\\Form',
......
<?php namespace System\DB;
<?php namespace System;
use System\Config;
class Manager {
class DB {
/**
* The established database connections.
......@@ -17,8 +15,8 @@ class Manager {
*
* Note: Database connections are managed as singletons.
*
* @param string $connection
* @return Connection
* @param string $connection
* @return DB\Connection
*/
public static function connection($connection = null)
{
......@@ -34,7 +32,7 @@ class Manager {
throw new \Exception("Database connection [$connection] is not defined.");
}
static::$connections[$connection] = new Connection($connection, (object) $config, new Connector);
static::$connections[$connection] = new DB\Connection($connection, (object) $config, new DB\Connector);
}
return static::$connections[$connection];
......@@ -43,9 +41,9 @@ class Manager {
/**
* Begin a fluent query against a table.
*
* @param string $table
* @param string $connection
* @return Query
* @param string $table
* @param string $connection
* @return DB\Query
*/
public static function table($table, $connection = null)
{
......
<?php namespace System\DB\Eloquent;
use System\DB;
use System\Str;
use System\Config;
use System\Inflector;
use System\Paginator;
use System\DB\Manager;
abstract class Model {
......@@ -135,7 +135,7 @@ abstract class Model {
// Since this method is only used for instantiating models for querying
// purposes, we will go ahead and set the Query instance on the model.
$model->query = Manager::connection(static::$connection)->table(static::table($class));
$model->query = DB::connection(static::$connection)->table(static::table($class));
return $model;
}
......@@ -367,7 +367,7 @@ abstract class Model {
// Since the model was instantiated using "new", a query instance has not been set.
// Only models being used for querying have their query instances set by default.
$this->query = Manager::connection(static::$connection)->table(static::table($model));
$this->query = DB::connection(static::$connection)->table(static::table($model));
if (property_exists($model, 'timestamps') and $model::$timestamps)
{
......@@ -416,7 +416,7 @@ abstract class Model {
// delete statement to the query instance.
if ( ! $this->exists) return $this->query->delete();
return Manager::connection(static::$connection)->table(static::table(get_class($this)))->delete($this->id);
return DB::connection(static::$connection)->table(static::table(get_class($this)))->delete($this->id);
}
/**
......
<?php namespace System\Session;
use System\Config;
use System\DB\Manager;
class DB implements Driver, Sweeper {
......@@ -71,7 +70,7 @@ class DB implements Driver, Sweeper {
*/
private function table()
{
return Manager::connection()->table(Config::get('session.table'));
return \System\DB::connection()->table(Config::get('session.table'));
}
}
\ No newline at end of file
......@@ -302,7 +302,7 @@ class Validator {
{
if ( ! isset($parameters[1])) $parameters[1] = $attribute;
return DB\Manager::connection()->table($parameters[0])->where($parameters[1], '=', $this->attributes[$attribute])->count() == 0;
return DB::connection()->table($parameters[0])->where($parameters[1], '=', $this->attributes[$attribute])->count() == 0;
}
/**
......
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