Added support for in-memory SQLite databases.
This commit is contained in:
parent
829088f3d1
commit
5f3d40b76c
|
@ -47,14 +47,19 @@ public static function connect($connection)
|
||||||
* Establish a PDO connection to a SQLite database.
|
* Establish a PDO connection to a SQLite database.
|
||||||
*
|
*
|
||||||
* SQLite database paths can be specified either relative to the application/db
|
* SQLite database paths can be specified either relative to the application/db
|
||||||
* directory, or as an absolute path to any location on the file system.
|
* directory, or as an absolute path to any location on the file system. In-memory
|
||||||
|
* databases are also supported.
|
||||||
*
|
*
|
||||||
* @param object $config
|
* @param object $config
|
||||||
* @return PDO
|
* @return PDO
|
||||||
*/
|
*/
|
||||||
private static function connect_to_sqlite($config)
|
private static function connect_to_sqlite($config)
|
||||||
{
|
{
|
||||||
if (file_exists($path = DATABASE_PATH.$config->database.'.sqlite'))
|
if ($config->database == ':memory:')
|
||||||
|
{
|
||||||
|
return new \PDO('sqlite::memory:', null, null, static::$options);
|
||||||
|
}
|
||||||
|
elseif (file_exists($path = DATABASE_PATH.$config->database.'.sqlite'))
|
||||||
{
|
{
|
||||||
return new \PDO('sqlite:'.$path, null, null, static::$options);
|
return new \PDO('sqlite:'.$path, null, null, static::$options);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue