/** * @return array */ private function getFilesFromFolder() { $files = array(); foreach (System::getDirectoryIterator($this->source) as $fileInfo) { if (!$fileInfo->isDot() && !$fileInfo->isDir()) { $files[] = $fileInfo->getFilename(); } } return $files; }
/** * For each extracted database, dump a JSON file with the detected structure. * * @param $path Output folder in which to dump the output * @throws InvalidPathException when file does not exist or is invalid * @return bool */ public function output($path, $databases = []) { $fileExists = System::file_exists($path); if (!$fileExists || $fileExists && !System::is_dir($path)) { throw new InvalidPathException($path); } foreach ($databases as $database) { $filename = $path . DIRECTORY_SEPARATOR . $database->Name . '-' . date('Y-m-d') . '-' . time() . '.json'; System::file_put_contents($filename, json_encode($database, JSON_PRETTY_PRINT)); } return true; }
protected function extractDatabaseDefinition($databaseName) { if ($this->databaseFilter !== $databaseName) { return; } $this->PDO->query("use " . $databaseName); $tables = $this->PDO->query('SHOW TABLES'); foreach ($tables as $table) { System::flush(); $this->extractTableDefinition($table[0], $databaseName); } }