$found = false; $dbName = args(2) == "" ? $_REQUEST['dbName'] : args(2); foreach (Database::all() as $dbObject) { if ($dbObject->name == $dbName) { echo json_encode($dbObject->tables); $found = true; } } if (!$found) { echo json_encode(array("Status" => "ERROR", "Error" => "{$dbName} not found")); } break; } break; case "xml": $dbObjects = Database::all(); header("Content-type: text/xml"); echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<databaselist>\n"; foreach ($dbObjects as $dbObject) { echo "<database>\n"; echo "\t<name>" . $dbObject->name . "</name>\n"; echo "\t<numtables>" . count($dbObject->tables) . "</numtables>\n"; echo "\t<tablelist>\n"; foreach ($dbObject->tables as $table) { echo "\t\t<table>" . $table . "</table>\n"; } echo "\t</tablelist>\n"; echo "</database>\n"; } echo "</databaselist>"; break;