if ($this->conn) {
if ($this->adapter == "mysql") {
$schemaSql = $this->listDatabases();
if ($this->rowCount($schemaSql)) {
while ($schema = $this->fetchArray($schemaSql)) {
$output .= '{"name": "' . $schema[0] . '"';
$this->selectDB($schema[0]);
$tableSql = $this->listTables();
if ($this->rowCount($tableSql)) {
$output .= ',"items": [';
while ($table = $this->fetchArray($tableSql)) {
$countSql = $this->query("SELECT COUNT(*) AS `RowCount` FROM `" . $table[0] . "`");
$rowCount = (int)($this->result($countSql, 0, "RowCount"));
$output .= '{"name":"' . $table[0] . '","rowcount":' . $rowCount . '},';
}
if (substr($output, -1) == ",")
$output = substr($output, 0, -1);
$output .= ']';
}
$output .= '},';
}
$output = substr($output, 0, -1);
}
} else if ($this->adapter == "sqlite") {
function rowCount($resultSet) {
if (!$resultSet)
return false;
if ($this->conn) {
if ($this->method == "pdo") {
return $resultSet->rowCount();
//return count($resultSet->fetchAll());
} else if ($this->method == "mysql") {
return @mysql_num_rows($resultSet);
} else if ($this->method == "sqlite") {
return @sqlite_num_rows($resultSet);
}
}
}