From 40ad90502c08148f8739d9f7664f4246e6970a05 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Fri, 1 Aug 2014 08:04:54 +0000 Subject: [PATCH] dblayer : Add dropTable support git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1644 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- dblayer.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/dblayer.php b/dblayer.php index da11c14..41f8f7f 100644 --- a/dblayer.php +++ b/dblayer.php @@ -689,6 +689,32 @@ class dblayer extends PDO return $arr; } + /** Drop the table */ + public function dropTable () + { + if ($this->db === null) + throw new Exception (_("Database not connected")); + switch ($this->db->getAttribute(PDO::ATTR_DRIVER_NAME)) + { + case "sqlite": + $sql = "DROP TABLE `$this->tableprefix$this->table`"; + break; + case "mysql": + $sql = "DROP TABLE `$this->tableprefix$this->table`"; + break; + case "pgsql": + $sql = "DROP TABLE `$this->tableprefix$this->table`"; + break; + default: + throw new Exception (sprintf (_("Unknown DB engine for drop table '%s'"), + $this->db->getAttribute(PDO::ATTR_DRIVER_NAME)), + 500); + } + if ($this->debug) + echo "$sql\n"; + return $this->db->exec($sql); + } + /** Create the table defined by the differents fields. Define the SQL syntax based on SQL engines $table = "dns zones";