From 5f3d40b76c82907cbee6d0af1345c01e4e77352a Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 1 Aug 2011 08:47:45 -0500 Subject: [PATCH] Added support for in-memory SQLite databases. --- system/db/connector.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/system/db/connector.php b/system/db/connector.php index 769f4f27..c93e34cd 100644 --- a/system/db/connector.php +++ b/system/db/connector.php @@ -47,14 +47,19 @@ public static function connect($connection) * Establish a PDO connection to a SQLite database. * * 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 * @return PDO */ 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); }