$match) { $table_pos[$match[1]] = "$match[2]em; left: $match[3]"; $table_pos_js[] = "\n\t'" . addcslashes($match[1], "\r\n'\\") . "': [ $match[2], $match[3] ]"; } $top = 0; $left = -14; $schema = array(); $referenced = array(); $result = $mysql->query("SHOW TABLE STATUS"); while ($row = $result->fetch_assoc()) { if (!isset($row["Engine"])) { // view continue; } $pos = 0; $schema[$row["Name"]]["fields"] = array(); foreach (fields($row["Name"]) as $name => $field) { $pos += 1.25; $field["pos"] = $pos; $schema[$row["Name"]]["fields"][$name] = $field; } $schema[$row["Name"]]["pos"] = ($table_pos[$row["Name"]] ? $table_pos[$row["Name"]] : $top); if ($row["Engine"] == "InnoDB") { foreach (foreign_keys($row["Name"]) as $val) { if (!$val["db"]) { $schema[$row["Name"]]["references"][$val["table"]][$left] = array_combine($val["source"], $val["target"]); $referenced[$val["table"]][$left] = $val["target"]; $left -= 2; } } } $top = max($top, $schema[$row["Name"]]["pos"] + 2.5 + $pos); } $result->free(); ?>