$field) {
if (isset($field["privileges"]["select"])) {
$columns[] = $key;
}
$rights += $field["privileges"];
}
if (isset($rights["insert"])) {
//! pass search values forth and back
echo '
' . lang('New item') . "
\n";
}
if (!$columns) {
echo "" . lang('Unable to select the table') . ($fields ? "" : ": " . $mysql->error) . ".
\n";
} else {
$indexes = indexes($_GET["select"]);
echo "\n";
echo "
\n";
$result = $mysql->query("SELECT SQL_CALC_FOUND_ROWS " . implode(", ", $select) . " FROM " . idf_escape($_GET["select"]) . ($where ? " WHERE " . implode(" AND ", $where) : "") . ($order ? " ORDER BY " . implode(", ", $order) : "") . (strlen($limit) ? " LIMIT " . intval($limit) . " OFFSET " . ($limit * $_GET["page"]) : ""));
if (!$result->num_rows) {
echo "" . lang('No rows.') . "
\n";
} else {
$found_rows = $mysql->result($mysql->query(" SELECT FOUND_ROWS()")); // space for mysql.trace_mode
$foreign_keys = array();
foreach (foreign_keys($_GET["select"]) as $foreign_key) {
foreach ($foreign_key["source"] as $val) {
$foreign_keys[$val][] = $foreign_key;
}
}
$childs = array();
/* slow-down
if ($mysql->server_info >= 5) {
// would be possible in earlier versions too, but only by examining all tables (in all databases)
$result1 = $mysql->query("SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_SCHEMA = '" . $mysql->escape_string($_GET["db"]) . "' AND REFERENCED_TABLE_NAME = '" . $mysql->escape_string($_GET["select"]) . "' ORDER BY ORDINAL_POSITION");
while ($row1 = $result1->fetch_assoc()) {
$childs[$row1["CONSTRAINT_NAME"]]["db"] = $row1["TABLE_SCHEMA"];
$childs[$row1["CONSTRAINT_NAME"]]["table"] = $row1["TABLE_NAME"];
$childs[$row1["CONSTRAINT_NAME"]]["source"][] = $row1["REFERENCED_COLUMN_NAME"];
$childs[$row1["CONSTRAINT_NAME"]]["target"][] = $row1["COLUMN_NAME"];
}
$result1->free();
}
*/
echo "\n";
if (intval($limit) && $found_rows > $limit) {
echo "" . lang('Page') . ":\n";
for ($i=0; $i < $found_rows / $limit; $i++) {
echo ($i == $_GET["page"] ? $i + 1 : '' . ($i + 1) . "") . "\n";
}
echo "
\n";
}
}
$result->free();
}