aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilly Micieli <micieli@laposte.net>2019-10-25 20:29:20 +0200
committerWilly Micieli <micieli@laposte.net>2019-10-25 20:29:20 +0200
commit72c85a03aac6ad0faf9b7cbd523fefa430e09cd0 (patch)
tree59fd49cdeddb97d104f981e10e266df44d3a57bb
parent165ddcf25bed9ad937efff165059f99e3d3597c7 (diff)
downloadimperium-72c85a03aac6ad0faf9b7cbd523fefa430e09cd0.zip
imperium-72c85a03aac6ad0faf9b7cbd523fefa430e09cd0.tar.gz
throw exception if not connected add helper
-rw-r--r--helpers/admin.php21
-rw-r--r--imperium/Connexion/Connect.php29
2 files changed, 38 insertions, 12 deletions
diff --git a/helpers/admin.php b/helpers/admin.php
index fa6e722..07b8da0 100644
--- a/helpers/admin.php
+++ b/helpers/admin.php
@@ -347,6 +347,27 @@
return connect(db('driver'), db('base'), db('username'), db('password'), db('host'), db('dump'));
}
+ } if( ! function_exists('is_not_connected'))
+ {
+ /**
+ *
+ * @return bool
+ *
+ * @throws Kedavra
+ *
+ */
+ function is_not_connected() : bool
+ {
+ try{
+
+ return ! instance()->pdo() instanceof PDO;
+ }catch (Kedavra $exception)
+ {
+
+ return true;
+ }
+
+ }
}
if( ! function_exists('assign'))
{
diff --git a/imperium/Connexion/Connect.php b/imperium/Connexion/Connect.php
index 71c92cf..43d1ae7 100644
--- a/imperium/Connexion/Connect.php
+++ b/imperium/Connexion/Connect.php
@@ -308,23 +308,28 @@
return $this->driver() === SQLITE;
}
-
- /**
- *
- * Return the PDO instance on success
- *
- * @method instance
- *
- *
- * @return PDO
- *
- */
+
+ /**
+ *
+ * Return the PDO instance on success
+ *
+ * @method instance
+ *
+ *
+ * @return PDO
+ *
+ * @throws Kedavra
+ *
+ */
public function pdo() : PDO
{
$instance = $this->getpdo();
- return is_string($instance) ? new PDO('sqlite::memory:') : $instance;
+ if (is_string($instance))
+ throw new Kedavra($instance);
+ else
+ return $instance;
}
/**