/** * Get full database structure * * @param string $dsn Datasource name * @param bool $count Count each table entries * * @return mixed * @throws Exception */ static function getDatabaseStructure($dsn, $count = false) { $databases = CImportTools::getAllDatabaseInfo(); if (!isset($databases[$dsn])) { throw new Exception("DSN not found : {$dsn}"); } $db_info = $databases[$dsn]; $ds = CSQLDataSource::get($dsn); // Description file $description = new DOMDocument(); $description->load($db_info["description_file"]); $description->_xpath = new DOMXPath($description); $db_info["description"] = $description; // Tables $table_names = $ds->loadTables(); $tables = array(); foreach ($table_names as $_table_name) { $_table_info = CImportTools::getTableInfo($ds, $_table_name); if ($count) { $_table_info["count"] = $ds->loadResult("SELECT COUNT(*) FROM {$_table_name}"); } $tables[$_table_name] = $_table_info; } $db_info["tables"] = $tables; return $db_info; }
<?php /** * $Id$ * * @category ImportTools * @package Mediboard * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ * @link http://www.mediboard.org */ CCanDo::checkAdmin(); $databases = CImportTools::getAllDatabaseInfo(); foreach ($databases as $_dsn => &$_info) { $_info = CImportTools::getDatabaseStructure($_dsn, true); } $smarty = new CSmartyDP(); $smarty->assign("databases", $databases); $smarty->display("vw_database_explorer.tpl");