/** * @param File[] $files */ private function importDumpInSecondaryDb($files) { $inlineFiles = ''; foreach ($files as $file) { $inlineFiles .= ' ' . escapeshellarg($file->getPath()); } $command = sprintf(self::CMD_IMPORT_DB, escapeshellarg(self::DB_SECONDARY), $inlineFiles); self::$shellExecutor->execute($command); }
/** * @param DatabaseSettings $settings * * @return \string[] */ private function getTablesToExport(DatabaseSettings $settings) { $tableListCommand = sprintf(self::MYSQL_QUERY_STRUCTURE, escapeshellarg($settings->getDbHost()), escapeshellarg($settings->getDbUser()), $settings->getDbPort(), escapeshellarg($settings->getDbPass()), escapeshellarg($settings->getDbName()), escapeshellarg('SHOW TABLES')); $rawTablesList = $this->shellExecutor->execute($tableListCommand); $tablesList = explode("\n", $rawTablesList); foreach ($tablesList as $index => $table) { $isLegend = $table === 'Tables_in_' . $settings->getDbName(); $isNotValidTable = empty($table); $isIgnoredTable = is_array($settings->getIgnoredTables()) && in_array($table, $settings->getIgnoredTables()); if ($isLegend || $isNotValidTable || $isIgnoredTable) { unset($tablesList[$index]); } } return array_values($tablesList); }