/** * Drop a database table * Destructive and dangerous - drops entire table and all data * Will throw errors if user does not have proper permissions */ public function dropDatabase($database) { $sql = "DROP DATABASE " . $database; // Add query to log \Spot\Log::addQuery($this, $sql); return $this->connection()->exec($sql); }
/** * Truncate a database table * Should delete all rows and reset serial/auto_increment keys to 0 */ public function truncateDatasource($datasource) { $sql = "DELETE FROM " . $datasource; // Add query to log \Spot\Log::addQuery($this, $sql); try { return $this->connection()->exec($sql); } catch (\PDOException $e) { // Table does not exist if ($e->getCode() == "42S02") { throw new \Spot\Exception_Datasource_Missing("Table or datasource '" . $datasource . "' does not exist"); } // Re-throw exception throw $e; } }