From b4241e1f300c7b68e9869f0aaddfb258746ca4e0 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Mon, 2 Feb 2015 13:49:33 +0000 Subject: [PATCH] dblayer : Check if the database is connected before using it git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1985 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- dblayer.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/dblayer.php b/dblayer.php index 7f69487..f6d3cdb 100644 --- a/dblayer.php +++ b/dblayer.php @@ -167,7 +167,7 @@ class dblayer extends PDO /** Return the connected database name from DSN used to connect */ public function databasename () { - if ($this === null) + if ($this->sep === "") throw new Exception (dgettext("domframework", "Database not connected"), 500); $vals = explode (";", substr (strstr ($this->dsn, ":"), 1)); @@ -185,7 +185,7 @@ class dblayer extends PDO /** Return all the tables available in the database */ public function listTables () { - if ($this === null) + if ($this->sep === "") throw new Exception (dgettext("domframework", "Database not connected"), 500); switch ($this->getAttribute(PDO::ATTR_DRIVER_NAME)) @@ -515,7 +515,7 @@ class dblayer extends PDO public function insert ($datas) { if ($this->debug) echo "== Entering insert\n"; - if ($this === null) + if ($this->sep === "") throw new Exception (dgettext("domframework", "Database not connected"), 500); if ($this->unique === null) @@ -605,7 +605,7 @@ class dblayer extends PDO $whereOr=false) { if ($this->debug) echo "== Entering read\n"; - if ($this === null) + if ($this->sep === "") throw new Exception (dgettext("domframework", "Database not connected"), 500); if ($select !== null && !is_array ($select)) @@ -721,7 +721,7 @@ class dblayer extends PDO public function update ($updatekey, $datas) { if ($this->debug) echo "== Entering update\n"; - if ($this === null) + if ($this->sep === "") throw new Exception (dgettext("domframework", "Database not connected"), 500); if (count ($this->fields) === 0) @@ -806,7 +806,7 @@ class dblayer extends PDO public function delete ($deletekey) { if ($this->debug) echo "== Entering delete\n"; - if ($this === null) + if ($this->sep === "") throw new Exception (dgettext("domframework", "Database not connected")); $req = "DELETE FROM $this->sep$this->tableprefix$this->table$this->sep "; $req .= "WHERE $this->primary = :primary"; @@ -843,7 +843,7 @@ class dblayer extends PDO public function dropTable () { if ($this->debug) echo "== Entering dropTables\n"; - if ($this === null) + if ($this->sep === "") throw new Exception (dgettext("domframework", "Database not connected")); $sql = "DROP TABLE $this->sep$this->tableprefix$this->table$this->sep"; if ($this->debug) @@ -870,7 +870,7 @@ class dblayer extends PDO public function createTable () { if ($this->debug) echo "== Entering createTable\n"; - if ($this === null) + if ($this->sep === "") throw new Exception (dgettext("domframework", "Database not connected"), 500); if (count ($this->fields) === 0)