diff --git a/adminer/db.inc.php b/adminer/db.inc.php index bb4464db..06b5b60b 100644 --- a/adminer/db.inc.php +++ b/adminer/db.inc.php @@ -99,15 +99,17 @@ if ($adminer->homepage()) { echo '' . (preg_match('~materialized~i', $type) ? lang('Materialized view') : lang('View')) . ''; echo '?'; } else { - foreach (array( - "Engine" => array(), - "Collation" => array(), - "Data_length" => array("create", lang('Alter table')), - "Index_length" => array("indexes", lang('Alter indexes')), - "Data_free" => array("edit", lang('New item')), - "Auto_increment" => array("auto_increment=1&create", lang('Alter table')), - "Rows" => array("select", lang('Select data')), - ) as $key => $link) { + foreach ( + array( + "Engine" => array(), + "Collation" => array(), + "Data_length" => array("create", lang('Alter table')), + "Index_length" => array("indexes", lang('Alter indexes')), + "Data_free" => array("edit", lang('New item')), + "Auto_increment" => array("auto_increment=1&create", lang('Alter table')), + "Rows" => array("select", lang('Select data')), + ) as $key => $link + ) { $id = " id='$key-" . h($name) . "'"; echo ($link ? "" . (support("table") || $key == "Rows" || (support("indexes") && $key != "Data_length") ? "?" diff --git a/adminer/drivers/mssql.inc.php b/adminer/drivers/mssql.inc.php index 753b8806..c40a3c63 100644 --- a/adminer/drivers/mssql.inc.php +++ b/adminer/drivers/mssql.inc.php @@ -310,9 +310,11 @@ if (isset($_GET["mssql"])) { function table_status($name = "") { $return = array(); - foreach (get_rows("SELECT ao.name AS Name, ao.type_desc AS Engine, (SELECT value FROM fn_listextendedproperty(default, 'SCHEMA', schema_name(schema_id), 'TABLE', ao.name, null, null)) AS Comment + foreach ( + get_rows("SELECT ao.name AS Name, ao.type_desc AS Engine, (SELECT value FROM fn_listextendedproperty(default, 'SCHEMA', schema_name(schema_id), 'TABLE', ao.name, null, null)) AS Comment FROM sys.all_objects AS ao -WHERE schema_id = SCHEMA_ID(" . q(get_schema()) . ") AND type IN ('S', 'U', 'V') " . ($name != "" ? "AND name = " . q($name) : "ORDER BY name")) as $row) { +WHERE schema_id = SCHEMA_ID(" . q(get_schema()) . ") AND type IN ('S', 'U', 'V') " . ($name != "" ? "AND name = " . q($name) : "ORDER BY name")) as $row + ) { if ($name != "") { return $row; } @@ -366,11 +368,13 @@ WHERE o.schema_id = SCHEMA_ID(" . q(get_schema()) . ") AND o.type IN ('S', 'U', function indexes($table, $connection2 = null) { $return = array(); // sp_statistics doesn't return information about primary key - foreach (get_rows("SELECT i.name, key_ordinal, is_unique, is_primary_key, c.name AS column_name, is_descending_key + foreach ( + get_rows("SELECT i.name, key_ordinal, is_unique, is_primary_key, c.name AS column_name, is_descending_key FROM sys.indexes i INNER JOIN sys.index_columns ic ON i.object_id = ic.object_id AND i.index_id = ic.index_id INNER JOIN sys.columns c ON ic.object_id = c.object_id AND ic.column_id = c.column_id -WHERE OBJECT_NAME(i.object_id) = " . q($table), $connection2) as $row) { +WHERE OBJECT_NAME(i.object_id) = " . q($table), $connection2) as $row + ) { $name = $row["name"]; $return[$name]["type"] = ($row["is_primary_key"] ? "PRIMARY" : ($row["is_unique"] ? "UNIQUE" : "INDEX")); $return[$name]["lengths"] = array(); @@ -492,7 +496,8 @@ WHERE OBJECT_NAME(i.object_id) = " . q($table), $connection2) as $row) { } elseif (!queries(($val[0] != "PRIMARY" ? "CREATE $val[0] " . ($val[0] != "INDEX" ? "INDEX " : "") . idf_escape($val[1] != "" ? $val[1] : uniqid($table . "_")) . " ON " . table($table) : "ALTER TABLE " . table($table) . " ADD PRIMARY KEY" - ) . " (" . implode(", ", $val[2]) . ")")) { + ) . " (" . implode(", ", $val[2]) . ")") + ) { return false; } } @@ -679,12 +684,14 @@ WHERE sys1.xtype = 'TR' AND sys2.name = " . q($table)) as $row $on_actions = str_replace('RESTRICT|', '', $on_actions); $types = array(); $structured_types = array(); - foreach (array( //! use sys.types - lang('Numbers') => array("tinyint" => 3, "smallint" => 5, "int" => 10, "bigint" => 20, "bit" => 1, "decimal" => 0, "real" => 12, "float" => 53, "smallmoney" => 10, "money" => 20), - lang('Date and time') => array("date" => 10, "smalldatetime" => 19, "datetime" => 19, "datetime2" => 19, "time" => 8, "datetimeoffset" => 10), - lang('Strings') => array("char" => 8000, "varchar" => 8000, "text" => 2147483647, "nchar" => 4000, "nvarchar" => 4000, "ntext" => 1073741823), - lang('Binary') => array("binary" => 8000, "varbinary" => 8000, "image" => 2147483647), - ) as $key => $val) { + foreach ( + array( //! use sys.types + lang('Numbers') => array("tinyint" => 3, "smallint" => 5, "int" => 10, "bigint" => 20, "bit" => 1, "decimal" => 0, "real" => 12, "float" => 53, "smallmoney" => 10, "money" => 20), + lang('Date and time') => array("date" => 10, "smalldatetime" => 19, "datetime" => 19, "datetime2" => 19, "time" => 8, "datetimeoffset" => 10), + lang('Strings') => array("char" => 8000, "varchar" => 8000, "text" => 2147483647, "nchar" => 4000, "nvarchar" => 4000, "ntext" => 1073741823), + lang('Binary') => array("binary" => 8000, "varbinary" => 8000, "image" => 2147483647), + ) as $key => $val + ) { $types += $val; $structured_types[$key] = array_keys($val); } diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index d255e909..d78bef82 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -876,7 +876,8 @@ if (!defined("DRIVER")) { $name = ($target == DB ? table("copy_$table") : idf_escape($target) . "." . table($table)); $view = view($table); if (($_POST["overwrite"] && !queries("DROP VIEW IF EXISTS $name")) - || !queries("CREATE VIEW $name AS $view[select]")) { //! USE to avoid db.table + || !queries("CREATE VIEW $name AS $view[select]") //! USE to avoid db.table + ) { return false; } } @@ -1175,14 +1176,16 @@ if (!defined("DRIVER")) { function driver_config() { $types = array(); ///< @var array [$type => $maximum_unsigned_length, ...] $structured_types = array(); ///< @var array [$description => [$type, ...], ...] - foreach (array( - lang('Numbers') => array("tinyint" => 3, "smallint" => 5, "mediumint" => 8, "int" => 10, "bigint" => 20, "decimal" => 66, "float" => 12, "double" => 21), - lang('Date and time') => array("date" => 10, "datetime" => 19, "timestamp" => 19, "time" => 10, "year" => 4), - lang('Strings') => array("char" => 255, "varchar" => 65535, "tinytext" => 255, "text" => 65535, "mediumtext" => 16777215, "longtext" => 4294967295), - lang('Lists') => array("enum" => 65535, "set" => 64), - lang('Binary') => array("bit" => 20, "binary" => 255, "varbinary" => 65535, "tinyblob" => 255, "blob" => 65535, "mediumblob" => 16777215, "longblob" => 4294967295), - lang('Geometry') => array("geometry" => 0, "point" => 0, "linestring" => 0, "polygon" => 0, "multipoint" => 0, "multilinestring" => 0, "multipolygon" => 0, "geometrycollection" => 0), - ) as $key => $val) { + foreach ( + array( + lang('Numbers') => array("tinyint" => 3, "smallint" => 5, "mediumint" => 8, "int" => 10, "bigint" => 20, "decimal" => 66, "float" => 12, "double" => 21), + lang('Date and time') => array("date" => 10, "datetime" => 19, "timestamp" => 19, "time" => 10, "year" => 4), + lang('Strings') => array("char" => 255, "varchar" => 65535, "tinytext" => 255, "text" => 65535, "mediumtext" => 16777215, "longtext" => 4294967295), + lang('Lists') => array("enum" => 65535, "set" => 64), + lang('Binary') => array("bit" => 20, "binary" => 255, "varbinary" => 65535, "tinyblob" => 255, "blob" => 65535, "mediumblob" => 16777215, "longblob" => 4294967295), + lang('Geometry') => array("geometry" => 0, "point" => 0, "linestring" => 0, "polygon" => 0, "multipoint" => 0, "multilinestring" => 0, "multipolygon" => 0, "geometrycollection" => 0), + ) as $key => $val + ) { $types += $val; $structured_types[$key] = array_keys($val); } diff --git a/adminer/drivers/oracle.inc.php b/adminer/drivers/oracle.inc.php index 3cebc994..f9f5b6f0 100644 --- a/adminer/drivers/oracle.inc.php +++ b/adminer/drivers/oracle.inc.php @@ -160,8 +160,8 @@ if (isset($_GET["oracle"])) { } } if (!(($where && queries("UPDATE " . table($table) . " SET " . implode(", ", $update) . " WHERE " . implode(" AND ", $where)) && $connection->affected_rows) - || queries("INSERT INTO " . table($table) . " (" . implode(", ", array_keys($set)) . ") VALUES (" . implode(", ", $set) . ")") - )) { + || queries("INSERT INTO " . table($table) . " (" . implode(", ", array_keys($set)) . ") VALUES (" . implode(", ", $set) . ")")) + ) { return false; } } @@ -322,12 +322,14 @@ ORDER BY 1") as $row function indexes($table, $connection2 = null) { $return = array(); $owner = where_owner(" AND ", "aic.table_owner"); - foreach (get_rows("SELECT aic.*, ac.constraint_type, atc.data_default + foreach ( + get_rows("SELECT aic.*, ac.constraint_type, atc.data_default FROM all_ind_columns aic LEFT JOIN all_constraints ac ON aic.index_name = ac.constraint_name AND aic.table_name = ac.table_name AND aic.index_owner = ac.owner LEFT JOIN all_tab_cols atc ON aic.column_name = atc.column_name AND aic.table_name = atc.table_name AND aic.index_owner = atc.owner WHERE aic.table_name = " . q($table) . "$owner -ORDER BY ac.constraint_type, aic.column_position", $connection2) as $row) { +ORDER BY ac.constraint_type, aic.column_position", $connection2) as $row + ) { $index_name = $row["INDEX_NAME"]; $column_name = $row["DATA_DEFAULT"]; $column_name = ($column_name ? trim($column_name, '"') : $row["COLUMN_NAME"]); // trim - possibly wrapped in quotes but never contains quotes inside @@ -521,12 +523,14 @@ ORDER BY PROCESS function driver_config() { $types = array(); $structured_types = array(); - foreach (array( - lang('Numbers') => array("number" => 38, "binary_float" => 12, "binary_double" => 21), - lang('Date and time') => array("date" => 10, "timestamp" => 29, "interval year" => 12, "interval day" => 28), //! year(), day() to second() - lang('Strings') => array("char" => 2000, "varchar2" => 4000, "nchar" => 2000, "nvarchar2" => 4000, "clob" => 4294967295, "nclob" => 4294967295), - lang('Binary') => array("raw" => 2000, "long raw" => 2147483648, "blob" => 4294967295, "bfile" => 4294967296), - ) as $key => $val) { + foreach ( + array( + lang('Numbers') => array("number" => 38, "binary_float" => 12, "binary_double" => 21), + lang('Date and time') => array("date" => 10, "timestamp" => 29, "interval year" => 12, "interval day" => 28), //! year(), day() to second() + lang('Strings') => array("char" => 2000, "varchar2" => 4000, "nchar" => 2000, "nvarchar2" => 4000, "clob" => 4294967295, "nclob" => 4294967295), + lang('Binary') => array("raw" => 2000, "long raw" => 2147483648, "blob" => 4294967295, "bfile" => 4294967296), + ) as $key => $val + ) { $types += $val; $structured_types[$key] = array_keys($val); } diff --git a/adminer/drivers/pgsql.inc.php b/adminer/drivers/pgsql.inc.php index b060995e..57b68d3e 100644 --- a/adminer/drivers/pgsql.inc.php +++ b/adminer/drivers/pgsql.inc.php @@ -209,8 +209,8 @@ if (isset($_GET["pgsql"])) { } } if (!(($where && queries("UPDATE " . table($table) . " SET " . implode(", ", $update) . " WHERE " . implode(" AND ", $where)) && $connection->affected_rows) - || queries("INSERT INTO " . table($table) . " (" . implode(", ", array_keys($set)) . ") VALUES (" . implode(", ", $set) . ")") - )) { + || queries("INSERT INTO " . table($table) . " (" . implode(", ", array_keys($set)) . ") VALUES (" . implode(", ", $set) . ")")) + ) { return false; } } @@ -450,11 +450,13 @@ ORDER BY a.attnum") as $row function foreign_keys($table) { global $on_actions; $return = array(); - foreach (get_rows("SELECT conname, condeferrable::int AS deferrable, pg_get_constraintdef(oid) AS definition + foreach ( + get_rows("SELECT conname, condeferrable::int AS deferrable, pg_get_constraintdef(oid) AS definition FROM pg_constraint WHERE conrelid = (SELECT pc.oid FROM pg_class AS pc INNER JOIN pg_namespace AS pn ON (pn.oid = pc.relnamespace) WHERE pc.relname = " . q($table) . " AND pn.nspname = current_schema()) AND contype = 'f'::char -ORDER BY conkey, conname") as $row) { +ORDER BY conkey, conname") as $row + ) { if (preg_match('~FOREIGN KEY\s*\((.+)\)\s*REFERENCES (.+)\((.+)\)(.*)$~iA', $row['definition'], $match)) { $row['source'] = array_map('Adminer\idf_unescape', array_map('trim', explode(',', $match[1]))); if (preg_match('~^(("([^"]|"")+"|[^"]+)\.)?"?("([^"]|"")+"|[^"]+)$~', $match[2], $match2)) { @@ -721,11 +723,7 @@ ORDER BY SPECIFIC_NAME'); function found_rows($table_status, $where) { global $connection; - if (preg_match( - "~ rows=([0-9]+)~", - $connection->result("EXPLAIN SELECT * FROM " . idf_escape($table_status["Name"]) . ($where ? " WHERE " . implode(" AND ", $where) : "")), - $regs - )) { + if (preg_match("~ rows=([0-9]+)~", $connection->result("EXPLAIN SELECT * FROM " . idf_escape($table_status["Name"]) . ($where ? " WHERE " . implode(" AND ", $where) : "")), $regs)) { return $regs[1]; } return false; @@ -918,14 +916,16 @@ AND typelem = 0" function driver_config() { $types = array(); $structured_types = array(); - foreach (array( //! arrays - lang('Numbers') => array("smallint" => 5, "integer" => 10, "bigint" => 19, "boolean" => 1, "numeric" => 0, "real" => 7, "double precision" => 16, "money" => 20), - lang('Date and time') => array("date" => 13, "time" => 17, "timestamp" => 20, "timestamptz" => 21, "interval" => 0), - lang('Strings') => array("character" => 0, "character varying" => 0, "text" => 0, "tsquery" => 0, "tsvector" => 0, "uuid" => 0, "xml" => 0), - lang('Binary') => array("bit" => 0, "bit varying" => 0, "bytea" => 0), - lang('Network') => array("cidr" => 43, "inet" => 43, "macaddr" => 17, "macaddr8" => 23, "txid_snapshot" => 0), - lang('Geometry') => array("box" => 0, "circle" => 0, "line" => 0, "lseg" => 0, "path" => 0, "point" => 0, "polygon" => 0), - ) as $key => $val) { //! can be retrieved from pg_type + foreach ( + array( //! arrays + lang('Numbers') => array("smallint" => 5, "integer" => 10, "bigint" => 19, "boolean" => 1, "numeric" => 0, "real" => 7, "double precision" => 16, "money" => 20), + lang('Date and time') => array("date" => 13, "time" => 17, "timestamp" => 20, "timestamptz" => 21, "interval" => 0), + lang('Strings') => array("character" => 0, "character varying" => 0, "text" => 0, "tsquery" => 0, "tsvector" => 0, "uuid" => 0, "xml" => 0), + lang('Binary') => array("bit" => 0, "bit varying" => 0, "bytea" => 0), + lang('Network') => array("cidr" => 43, "inet" => 43, "macaddr" => 17, "macaddr8" => 23, "txid_snapshot" => 0), + lang('Geometry') => array("box" => 0, "circle" => 0, "line" => 0, "lseg" => 0, "path" => 0, "point" => 0, "polygon" => 0), + ) as $key => $val //! can be retrieved from pg_type + ) { $types += $val; $structured_types[$key] = array_keys($val); } diff --git a/adminer/include/connect.inc.php b/adminer/include/connect.inc.php index 3a03a072..df1bf7bb 100644 --- a/adminer/include/connect.inc.php +++ b/adminer/include/connect.inc.php @@ -23,13 +23,15 @@ if (!(DB != "" ? $connection->select_db(DB) : isset($_GET["sql"]) || isset($_GET page_header(lang('Select database'), $error, false); echo "