From 21dccae75552ca52eed4f47dc2df1091dc3de669 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 20 Oct 2011 22:17:40 -0500 Subject: [PATCH] refactor sqlite connector to accept path in constructor. --- laravel/config/container.php | 2 +- laravel/database/connectors/sqlite.php | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/laravel/config/container.php b/laravel/config/container.php index e4de06d0..72dbc35e 100644 --- a/laravel/config/container.php +++ b/laravel/config/container.php @@ -53,7 +53,7 @@ 'laravel.database.connectors.sqlite' => array('resolver' => function($c) { - return new Database\Connectors\SQLite; + return new Database\Connectors\SQLite(DATABASE_PATH); }), 'laravel.database.connectors.mysql' => array('resolver' => function($c) diff --git a/laravel/database/connectors/sqlite.php b/laravel/database/connectors/sqlite.php index aeb6e972..ab67f52b 100644 --- a/laravel/database/connectors/sqlite.php +++ b/laravel/database/connectors/sqlite.php @@ -2,6 +2,24 @@ class SQLite extends Connector { + /** + * The path to the SQLite databases for the application. + * + * @var string + */ + protected $path; + + /** + * Create a new SQLite database connector instance. + * + * @param string $path + * @return void + */ + public function __construct($path) + { + $this->path = $path; + } + /** * Establish a PDO database connection for a given database configuration. * @@ -21,7 +39,7 @@ public function connect($config) // application. If we don't find the database there, we will assume the database // name is actually a full qualified path to the database on disk and attempt // to load it. If we still can't find it, we'll bail out. - elseif (file_exists($path = DATABASE_PATH.$config['database'].'.sqlite')) + elseif (file_exists($path = $this->path.$config['database'].'.sqlite')) { return new PDO('sqlite:'.$path, null, null, $options); }