Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Driver specific view detection

  • Loading branch information...
commit da6f1f850b903e9a43ee45dfe48e60009f81b0aa 1 parent fe3d395
@vrana authored
View
2  adminer/db.inc.php
@@ -165,7 +165,7 @@
foreach ($table_status as $row) {
$id = addcslashes($row["Name"], "\\'/");
echo "setHtml('Comment-$id', '" . nbsp($row["Comment"]) . "');\n";
- if (!eregi("view", $row["Engine"])) {
+ if (!is_view($row)) {
foreach (array("Engine", "Collation") as $key) {
echo "setHtml('$key-$id', '" . nbsp($row[$key]) . "');\n";
}
View
4 adminer/drivers/mssql.inc.php
@@ -304,6 +304,10 @@ function table_status($name = "") {
return $return;
}
+ function is_view($table_status) {
+ return $table_status["Engine"] == "VIEW";
+ }
+
function fk_support($table_status) {
return true;
}
View
9 adminer/drivers/mysql.inc.php
@@ -359,7 +359,6 @@ function table_status($name = "") {
$row["Comment"] = preg_replace('~(?:(.+); )?InnoDB free: .*~', '\\1', $row["Comment"]);
}
if (!isset($row["Rows"])) {
- $row["Engine"] = "VIEW";
$row["Comment"] = "";
}
if ($name != "") {
@@ -370,6 +369,14 @@ function table_status($name = "") {
return $return;
}
+ /** Find out whether the identifier is view
+ * @param array
+ * @return bool
+ */
+ function is_view($table_status) {
+ return !isset($table_status["Rows"]);
+ }
+
/** Check if table supports foreign keys
* @param array result of table_status
* @return bool
View
4 adminer/drivers/oracle.inc.php
@@ -202,6 +202,10 @@ function table_status($name = "") {
return $return;
}
+ function is_view($table_status) {
+ return $table_status["Engine"] == "view";
+ }
+
function fk_support($table_status) {
return true;
}
View
4 adminer/drivers/pgsql.inc.php
@@ -213,6 +213,10 @@ function table_status($name = "") {
return ($name != "" ? $return[$name] : $return);
}
+ function is_view($table_status) {
+ return $table_status["Engine"] == "view";
+ }
+
function fk_support($table_status) {
return true;
}
View
4 adminer/drivers/sqlite.inc.php
@@ -262,6 +262,10 @@ function table_status($name = "") {
return ($name != "" ? $return[$name] : $return);
}
+ function is_view($table_status) {
+ return $table_status["Engine"] == "view";
+ }
+
function fk_support($table_status) {
global $connection;
return !$connection->result("SELECT sqlite_compileoption_used('OMIT_FOREIGN_KEY')");
View
4 adminer/dump.inc.php
@@ -72,7 +72,7 @@
$table = (DB == "" || in_array($row["Name"], (array) $_POST["tables"]));
$data = (DB == "" || in_array($row["Name"], (array) $_POST["data"]));
if ($table || $data) {
- if (isset($row["Engine"])) {
+ if (!is_view($row)) {
if ($ext == "tar") {
ob_start();
}
@@ -197,7 +197,7 @@
$prefix = ereg_replace("_.*", "", $name);
$checked = ($TABLE == "" || $TABLE == (substr($TABLE, -1) == "%" ? "$prefix%" : $name)); //! % may be part of table name
$print = "<tr><td>" . checkbox("tables[]", $name, $checked, $name, "formUncheck('check-tables');");
- if (eregi("view", $row["Engine"])) {
+ if (is_view($row)) {
$views .= "$print\n";
} else {
echo "$print<td align='right'><label>" . ($row["Engine"] == "InnoDB" && $row["Rows"] ? "~ " : "") . $row["Rows"] . checkbox("data[]", $name, $checked, "", "formUncheck('check-data');") . "</label>\n";
View
2  adminer/include/adminer.inc.php
@@ -86,7 +86,7 @@ function fieldName($field, $order = 0) {
function selectLinks($tableStatus, $set = "") {
echo '<p class="tabs">';
$links = array("select" => lang('Select data'), "table" => lang('Show structure'));
- if (eregi("view", $tableStatus["Engine"])) {
+ if (is_view($tableStatus)) {
$links["view"] = lang('Alter view');
} else {
$links["create"] = lang('Alter table');
View
4 adminer/table.inc.php
@@ -6,7 +6,7 @@
}
$table_status = ($fields ? table_status($TABLE) : array());
-page_header(($fields && $table_status["Engine"] == "VIEW" ? lang('View') : lang('Table')) . ": " . h($TABLE), $error);
+page_header(($fields && is_view($table_status) ? lang('View') : lang('Table')) . ": " . h($TABLE), $error);
$adminer->selectLinks($table_status);
if ($fields) {
@@ -20,7 +20,7 @@
}
echo "</table>\n";
- if ($table_status["Engine"] != "VIEW") {
+ if (is_view($table_status)) {
echo "<h3>" . lang('Indexes') . "</h3>\n";
$indexes = indexes($TABLE);
if ($indexes) {
Please sign in to comment.
Something went wrong with that request. Please try again.