From 9d4d6e52bd7617ae5fa039d5b3dead4781e73efb Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Sat, 13 Aug 2011 22:23:07 -0500 Subject: [PATCH] refactor database structure... moved db\manager back to system\db.php --- application/config/aliases.php | 2 +- system/{db/manager.php => db.php} | 18 ++++++++---------- system/db/eloquent/model.php | 8 ++++---- system/session/db.php | 3 +-- system/validator.php | 2 +- 5 files changed, 15 insertions(+), 18 deletions(-) rename system/{db/manager.php => db.php} (79%) diff --git a/application/config/aliases.php b/application/config/aliases.php index bef65063..2403057f 100644 --- a/application/config/aliases.php +++ b/application/config/aliases.php @@ -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', diff --git a/system/db/manager.php b/system/db.php similarity index 79% rename from system/db/manager.php rename to system/db.php index f830e9f3..4af1eaf5 100644 --- a/system/db/manager.php +++ b/system/db.php @@ -1,8 +1,6 @@ -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); } /** diff --git a/system/session/db.php b/system/session/db.php index 34ba65df..eb941af9 100644 --- a/system/session/db.php +++ b/system/session/db.php @@ -1,7 +1,6 @@ table(Config::get('session.table')); + return \System\DB::connection()->table(Config::get('session.table')); } } \ No newline at end of file diff --git a/system/validator.php b/system/validator.php index 3a574f98..9e0f952c 100644 --- a/system/validator.php +++ b/system/validator.php @@ -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; } /**