original_string: 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();
      }
code: 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();
      }
code_tokens: 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 ( ) ; }
docstring: Callback for "database-truncate" command
docstring_tokens: Callback for database - truncate command