query("SELECT COUNT(*) FROM sqlite_master WHERE type = 'table'")->fetchColumn() > 0; if ($database_exists) { return $pdo; } foreach (scandir(__DIR__) as $file) { if (preg_match("/.*\.sql$/i", $file)) { $content = file_get_contents(__DIR__ . "/" . $file); $pdo->exec($content); } } return $pdo; }