Exemplo n.º 1
0
 /**
  * Execute command
  *
  * @param  InputInterface  $input  Input instance
  * @param  OutputInterface $output Output instance
  *
  * @return int|null|void
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     // ##################
     // Init
     // ##################
     $dbName = $input->getArgument('db');
     $output->writeln('<h2>Cleanup TYPO3 database</h2>');
     // ##############
     // Loop through databases
     // ##############
     if (empty($dbName)) {
         // ##############
         // All databases
         // ##############
         // Get list of databases
         $query = 'SELECT SCHEMA_NAME
                 FROM information_schema.SCHEMATA';
         $databaseList = DatabaseConnection::getCol($query);
         foreach ($databaseList as $dbName) {
             // Skip internal mysql databases
             if (in_array(strtolower($dbName), array('mysql', 'information_schema', 'performance_schema'))) {
                 continue;
             }
             // Check if database is TYPO3 instance
             $query = 'SELECT COUNT(*) as count
                         FROM information_schema.tables
                        WHERE table_schema = ' . DatabaseConnection::quote($dbName) . '
                          AND table_name = \'be_users\'';
             $isTypo3Database = DatabaseConnection::getOne($query);
             if ($isTypo3Database) {
                 $this->cleanupTypo3Database($dbName);
             }
         }
     } else {
         // ##############
         // One databases
         // ##############
         $this->cleanupTypo3Database($dbName);
     }
     return 0;
 }
Exemplo n.º 2
0
 /**
  * Show list of domains
  *
  * @param string $dbName Domain name
  */
 protected function showDomainList($dbName)
 {
     $query = 'SELECT domainName FROM sys_domain ORDER BY domainName ASC';
     $domainList = DatabaseConnection::getCol($query);
     $this->output->writeln('<p>Domain list of "' . $dbName . '":</p>');
     foreach ($domainList as $domain) {
         $this->output->writeln('<p>  ' . $domain . '</p>');
     }
     $this->output->writeln('');
 }
Exemplo n.º 3
0
 /**
  * Return list of databases
  *
  * @return array
  */
 public static function databaseList()
 {
     // Get list of databases
     $query = 'SELECT SCHEMA_NAME FROM information_schema.SCHEMATA';
     $ret = DatabaseConnection::getCol($query);
     // Filter mysql specific databases
     $ret = array_diff($ret, array('mysql', 'information_schema', 'performance_schema'));
     return $ret;
 }