controllers/commands/Database.php
public function cmdTruncateDatabase()
    {
        $all = $this->getParam('all');
        $tables = $this->getArguments();

        if (empty($tables) && empty($all)) {
            $this->errorAndExit($this->text('Invalid command'));
        }

        $confirm = null;

        if (!empty($tables)) {
            $confirm = $this->choose($this->text('Are you sure you want to empty the tables? It cannot be undone!'));
        } else if (!empty($all)) {
            $confirm = $this->choose($this->text('Are you sure you want to empty ALL tables in the database? It cannot be undone!'));
            $tables = $this->db->fetchColumnAll('SHOW TABLES');
        }

        if ($confirm === 'y') {
            foreach ($tables as $table) {
                $this->db->query("TRUNCATE TABLE `$table`")->execute();
            }
        }

        $this->output();
    }
public function cmdTruncateDatabase()
    {
        $all = $this->getParam('all');
        $tables = $this->getArguments();

        if (empty($tables) && empty($all)) {
            $this->errorAndExit($this->text('Invalid command'));
        }

        $confirm = null;

        if (!empty($tables)) {
            $confirm = $this->choose($this->text('Are you sure you want to empty the tables? It cannot be undone!'));
        } else if (!empty($all)) {
            $confirm = $this->choose($this->text('Are you sure you want to empty ALL tables in the database? It cannot be undone!'));
            $tables = $this->db->fetchColumnAll('SHOW TABLES');
        }

        if ($confirm === 'y') {
            foreach ($tables as $table) {
                $this->db->query("TRUNCATE TABLE `$table`")->execute();
            }
        }

        $this->output();
    }
public function cmdTruncateDatabase ( ) { $ all = $ this -> getParam ( 'all' ) ; $ tables = $ this -> getArguments ( ) ; if ( empty ( $ tables ) && empty ( $ all ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } $ confirm = null ; if ( ! empty ( $ tables ) ) { $ confirm = $ this -> choose ( $ this -> text ( 'Are you sure you want to empty the tables? It cannot be undone!' ) ) ; } else if ( ! empty ( $ all ) ) { $ confirm = $ this -> choose ( $ this -> text ( 'Are you sure you want to empty ALL tables in the database? It cannot be undone!' ) ) ; $ tables = $ this -> db -> fetchColumnAll ( 'SHOW TABLES' ) ; } if ( $ confirm === 'y' ) { foreach ( $ tables as $ table ) { $ this -> db -> query ( "TRUNCATE TABLE `$table`" ) -> execute ( ) ; } } $ this -> output ( ) ; }
Callback for "database-truncate" command
Callback for database - truncate command