$match) { $table_pos[$match[1]] = array($match[2], $match[3]); $table_pos_js[] = "\n\t'" . addcslashes($match[1], "\r\n'\\") . "': [ $match[2], $match[3] ]"; } $top = 0; $base_left = -.9; $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"]] : array($top, 0)); if ($row["Engine"] == "InnoDB") { foreach (foreign_keys($row["Name"]) as $val) { if (!$val["db"]) { if ($table_pos[$row["Name"]][1] || $table_pos[$row["Name"]][1]) { $left = min($table_pos[$row["Name"]][1], $table_pos[$val["table"]][1]) - .9; } else { $left = $base_left; $base_left -= .1; } $schema[$row["Name"]]["references"][$val["table"]][10000 * $left] = array_combine($val["source"], $val["target"]); $referenced[$val["table"]][10000 * $left] = $val["target"]; } } } $top = max($top, $schema[$row["Name"]]["pos"][0] + 2.5 + $pos); } $result->free(); ?>