refactor sqlite connector to accept path in constructor.
This commit is contained in:
@@ -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 @@
|
|||||||
|
|
||||||
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 {
|
|||||||
// 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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user