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";