public/include/Conn.php
public function clearDatabase()
    {
        try {
            $dsn = 'mysql:host=' . $this->host . ';dbname=' . $this->database;
            $options = [\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES UTF8'];
            $connect = new \PDO($dsn, $this->user, $this->pass, $options);
            $connect->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);

            $command = $connect->prepare("show tables");
            $command->setFetchMode(\PDO::FETCH_ASSOC);
            $command->execute();
            $results = $command->fetchAll();

            if(!empty($results)) {
                foreach ($results as $result) {
                    foreach ($result as $dba => $table){
                        $command = $connect->prepare("DROP TABLE IF EXISTS {$table}");
                        $command->execute();
                    }
                }
            }

        } catch (\PDOException $e) {
            return false;
        }
    }
public function clearDatabase()
    {
        try {
            $dsn = 'mysql:host=' . $this->host . ';dbname=' . $this->database;
            $options = [\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES UTF8'];
            $connect = new \PDO($dsn, $this->user, $this->pass, $options);
            $connect->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);

            $command = $connect->prepare("show tables");
            $command->setFetchMode(\PDO::FETCH_ASSOC);
            $command->execute();
            $results = $command->fetchAll();

            if(!empty($results)) {
                foreach ($results as $result) {
                    foreach ($result as $dba => $table){
                        $command = $connect->prepare("DROP TABLE IF EXISTS {$table}");
                        $command->execute();
                    }
                }
            }

        } catch (\PDOException $e) {
            return false;
        }
    }
public function clearDatabase ( ) { try { $ dsn = 'mysql:host=' . $ this -> host . ';dbname=' . $ this -> database ; $ options = [ \ PDO :: MYSQL_ATTR_INIT_COMMAND => 'SET NAMES UTF8' ] ; $ connect = new \ PDO ( $ dsn , $ this -> user , $ this -> pass , $ options ) ; $ connect -> setAttribute ( \ PDO :: ATTR_ERRMODE , \ PDO :: ERRMODE_EXCEPTION ) ; $ command = $ connect -> prepare ( "show tables" ) ; $ command -> setFetchMode ( \ PDO :: FETCH_ASSOC ) ; $ command -> execute ( ) ; $ results = $ command -> fetchAll ( ) ; if ( ! empty ( $ results ) ) { foreach ( $ results as $ result ) { foreach ( $ result as $ dba => $ table ) { $ command = $ connect -> prepare ( "DROP TABLE IF EXISTS {$table}" ) ; $ command -> execute ( ) ; } } } } catch ( \ PDOException $ e ) { return false ; } }
Limpa as tabelas presentes na database
Limpa as tabelas presentes na database