mirror of
https://github.com/vrana/adminer.git
synced 2025-08-12 09:34:10 +02:00
Report errors in get_rows()
This commit is contained in:
@@ -343,18 +343,15 @@ WHERE o.schema_id = SCHEMA_ID(" . q(get_schema()) . ") AND o.type IN ('S', 'U',
|
||||
}
|
||||
$return = array();
|
||||
// sp_statistics doesn't return information about primary key
|
||||
$result = $connection2->query("SELECT indexes.name, key_ordinal, is_unique, is_primary_key, columns.name AS column_name
|
||||
foreach (get_rows("SELECT indexes.name, key_ordinal, is_unique, is_primary_key, columns.name AS column_name
|
||||
FROM sys.indexes
|
||||
INNER JOIN sys.index_columns ON indexes.object_id = index_columns.object_id AND indexes.index_id = index_columns.index_id
|
||||
INNER JOIN sys.columns ON index_columns.object_id = columns.object_id AND index_columns.column_id = columns.column_id
|
||||
WHERE OBJECT_NAME(indexes.object_id) = " . q($table)
|
||||
);
|
||||
if ($result) {
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$return[$row["name"]]["type"] = ($row["is_primary_key"] ? "PRIMARY" : ($row["is_unique"] ? "UNIQUE" : "INDEX"));
|
||||
$return[$row["name"]]["lengths"] = array();
|
||||
$return[$row["name"]]["columns"][$row["key_ordinal"]] = $row["column_name"];
|
||||
}
|
||||
, $connection2) as $row) {
|
||||
$return[$row["name"]]["type"] = ($row["is_primary_key"] ? "PRIMARY" : ($row["is_unique"] ? "UNIQUE" : "INDEX"));
|
||||
$return[$row["name"]]["lengths"] = array();
|
||||
$return[$row["name"]]["columns"][$row["key_ordinal"]] = $row["column_name"];
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
@@ -835,7 +835,7 @@ if (!defined("DRIVER")) {
|
||||
*/
|
||||
function trigger_sql($table, $style) {
|
||||
$return = "";
|
||||
foreach (get_rows("SHOW TRIGGERS LIKE " . q(addcslashes($table, "%_"))) as $row) {
|
||||
foreach (get_rows("SHOW TRIGGERS LIKE " . q(addcslashes($table, "%_")), null, "-- ") as $row) {
|
||||
$return .= "\n" . ($style == 'CREATE+ALTER' ? "DROP TRIGGER IF EXISTS " . idf_escape($row["Trigger"]) . ";;\n" : "")
|
||||
. "CREATE TRIGGER " . idf_escape($row["Trigger"]) . " $row[Timing] $row[Event] ON " . table($row["Table"]) . " FOR EACH ROW\n$row[Statement];;\n";
|
||||
}
|
||||
|
@@ -251,7 +251,7 @@ ORDER BY a.attnum < 0, a.attnum"
|
||||
$return = array();
|
||||
$table_oid = $connection2->result("SELECT oid FROM pg_class WHERE relname = " . q($table));
|
||||
$columns = get_key_vals("SELECT attnum, attname FROM pg_attribute WHERE attrelid = $table_oid AND attnum > 0", $connection2);
|
||||
foreach (get_rows("SELECT relname, indisunique, indisprimary, indkey FROM pg_index i, pg_class ci WHERE i.indrelid = $table_oid AND ci.oid = i.indexrelid") as $row) {
|
||||
foreach (get_rows("SELECT relname, indisunique, indisprimary, indkey FROM pg_index i, pg_class ci WHERE i.indrelid = $table_oid AND ci.oid = i.indexrelid", $connection2) as $row) {
|
||||
$return[$row["relname"]]["type"] = ($row["indisprimary"] == "t" ? "PRIMARY" : ($row["indisunique"] == "t" ? "UNIQUE" : "INDEX"));
|
||||
$return[$row["relname"]]["columns"] = array();
|
||||
foreach (explode(" ", $row["indkey"]) as $indkey) {
|
||||
@@ -269,7 +269,8 @@ FROM information_schema.table_constraints tc
|
||||
LEFT JOIN information_schema.key_column_usage kcu USING (constraint_catalog, constraint_schema, constraint_name)
|
||||
LEFT JOIN information_schema.referential_constraints rc USING (constraint_catalog, constraint_schema, constraint_name)
|
||||
LEFT JOIN information_schema.constraint_column_usage ccu ON rc.unique_constraint_catalog = ccu.constraint_catalog AND rc.unique_constraint_schema = ccu.constraint_schema AND rc.unique_constraint_name = ccu.constraint_name
|
||||
WHERE tc.constraint_type = 'FOREIGN KEY' AND tc.table_name = " . q($table)) as $row) { //! there can be more unique_constraint_name
|
||||
WHERE tc.constraint_type = 'FOREIGN KEY' AND tc.table_name = " . q($table) //! there can be more unique_constraint_name
|
||||
) as $row) {
|
||||
$foreign_key = &$return[$row["constraint_name"]];
|
||||
if (!$foreign_key) {
|
||||
$foreign_key = $row;
|
||||
|
@@ -254,7 +254,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||
$row["Auto_increment"] = "";
|
||||
$return[$row["Name"]] = $row;
|
||||
}
|
||||
foreach (get_rows("SELECT * FROM sqlite_sequence") as $row) {
|
||||
foreach (get_rows("SELECT * FROM sqlite_sequence", null, "") as $row) {
|
||||
$return[$row["name"]]["Auto_increment"] = $row["seq"];
|
||||
}
|
||||
return ($name != "" ? $return[$name] : $return);
|
||||
|
Reference in New Issue
Block a user