Commit 21dccae7 authored by Taylor Otwell's avatar Taylor Otwell

refactor sqlite connector to accept path in constructor.

parent 23c79a03
...@@ -53,7 +53,7 @@ return array( ...@@ -53,7 +53,7 @@ return array(
'laravel.database.connectors.sqlite' => array('resolver' => function($c) '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) 'laravel.database.connectors.mysql' => array('resolver' => function($c)
......
...@@ -2,6 +2,24 @@ ...@@ -2,6 +2,24 @@
class SQLite extends Connector { 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. * Establish a PDO database connection for a given database configuration.
* *
...@@ -21,7 +39,7 @@ class SQLite extends Connector { ...@@ -21,7 +39,7 @@ class SQLite extends Connector {
// application. If we don't find the database there, we will assume the database // 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 // 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. // 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); return new PDO('sqlite:'.$path, null, null, $options);
} }
......
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