Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow anyone to construct a SqliteAdapter from a live PDO connection,…

… with optional connect string for display in exceptions.
  • Loading branch information...
commit ca762cbd7d3609af20d0380ada6f0bbf0f7f392a 1 parent b14a99d
@qris qris authored
Showing with 16 additions and 4 deletions.
  1. +16 −4 lib/adapters/SqliteAdapter.php
View
20 lib/adapters/SqliteAdapter.php
@@ -13,12 +13,24 @@
*/
class SqliteAdapter extends Connection
{
- protected function __construct($info)
+ public function __construct($info, $connection_string = NULL)
{
- if (!file_exists($info->host))
+ if ($info instanceof PDO)
+ {
+ $this->connection = $info;
+ $this->connection_string = $connection_string;
+ return;
+ }
+
+ if ($info->host != ':memory:' && !file_exists($info->host))
+ {
throw new DatabaseException("Could not find sqlite db: $info->host");
-
- $this->connection = new PDO("sqlite:$info->host",null,null,static::$PDO_OPTIONS);
+ }
+
+ $this->connection_string = "sqlite:$info->host";
+
+ $this->connection = new PDO($this->connection_string, null, null,
+ static::$PDO_OPTIONS);
}
public function limit($sql, $offset, $limit)
Please sign in to comment.
Something went wrong with that request. Please try again.