Permalink
Browse files

WIP: more unused code removed, support for MSSQL

  • Loading branch information...
juzna committed Jun 11, 2012
1 parent 690bdd7 commit f11ccf54185a43bf289aed4420897acd29bbb239
Showing with 31 additions and 29 deletions.
  1. +4 −4 adminer/include/design.inc.php
  2. +1 −0 adminer/include/functions.inc.php
  3. +25 −24 adminer/ndb.inc.php
  4. +1 −1 nette
@@ -75,10 +75,10 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "", $
echo "<div class='message'>" . implode("</div>\n<div class='message'>", $messages) . "</div>\n";
unset($_SESSION["messages"][$uri]);
}
- $databases = &get_session("dbs");
- if (DB != "" && $databases && !in_array(DB, $databases, true)) {
- $databases = null;
- }
+ // $databases = &get_session("dbs");
+ // if (DB != "" && $databases && !in_array(DB, $databases, true)) {
+ // $databases = null;
+ // }
if ($error) {
echo "<div class='error'>$error</div>\n";
}
@@ -296,6 +296,7 @@ function get_rows($query, $connection2 = null, $error = "<p class='error'>") {
$return[] = $row;
}
} elseif (!$result && !is_object($connection2) && $error && defined("PAGE_HEADER")) {
+ throw new Exception(error());
echo $error . error() . "\n";
}
return $return;
View
@@ -11,7 +11,7 @@
Nette\Loaders\NetteLoader::getInstance()->register();
$cred = $adminer->credentials();
-$db = new \Nette\Database\Connection("mysql:host=$cred[0];dbname=" . DB, $cred[1], $cred[2]);
+$db = new \Nette\Database\Connection("sqlsrv:server=$cred[0];Database=" . DB, $cred[1], $cred[2]);
$db->setDatabaseReflection(new \Nette\Database\Reflection\DiscoveredReflection());
@@ -36,13 +36,13 @@
page_header(lang('Nette Database query'), $error, array(), "", "<link rel='stylesheet' href='$codemirror_path/lib/codemirror.css'>");
if (!$error && $_POST) {
- $fp = false;
+ // $fp = false;
$query = $_POST["query"];
- if ($query) {
+ // if ($query) {
$query = eval("return ${query}->getSql();");
- if (function_exists('memory_get_usage')) {
- @ini_set("memory_limit", max(ini_bytes("memory_limit"), 2 * strlen($query) + memory_get_usage() + 8e6)); // @ - may be disabled, 2 - substr and trim, 8e6 - other variables
- }
+ // if (function_exists('memory_get_usage')) {
+ // @ini_set("memory_limit", max(ini_bytes("memory_limit"), 2 * strlen($query) + memory_get_usage() + 8e6)); // @ - may be disabled, 2 - substr and trim, 8e6 - other variables
+ // }
// if ($query != "" && strlen($query) < 1e6) { // don't add big queries
// $q = $query . (ereg(";[ \t\r\n]*\$", $query) ? "" : ";"); //! doesn't work with DELIMITER |
// if (!$history || reset(end($history)) != $q) { // no repeated queries
@@ -56,10 +56,10 @@
// $delimiter = ";";
$offset = 0;
$empty = true;
- $connection2 = connect(); // connection for exploring indexes and EXPLAIN (to not replace FOUND_ROWS()) //! PDO - silent error
- if (is_object($connection2) && DB != "") {
- $connection2->select_db(DB);
- }
+ // $connection2 = connect(); // connection for exploring indexes and EXPLAIN (to not replace FOUND_ROWS()) //! PDO - silent error
+ // if (is_object($connection2) && DB != "") {
+ // $connection2->select_db(DB);
+ // }
// $commands = 0;
$errors = array();
$error_lines = array();
@@ -103,6 +103,7 @@
$empty = false;
$q = $query; // substr($query, 0, $pos);
// $commands++;
+ var_dump(1);
$print = "<pre id='sql'><code class='jush-$jush'>" . shorten_utf8(trim($q), 1000) . "</code></pre>\n";
// if (!$_POST["only_errors"]) {
echo $print;
@@ -112,7 +113,7 @@
$start = microtime(); // microtime(true) is available since PHP 5
//! don't allow changing of character_set_results, convert encoding of displayed query
if ($connection->multi_query($q) && is_object($connection2) && preg_match("~^$space*USE\\b~isU", $q)) {
- $connection2->query($q);
+ // $connection2->query($q);
}
do {
$result = $connection->store_result();
@@ -127,7 +128,7 @@
break 2;
}
} elseif (is_object($result)) {
- $orgtables = select($result, $connection2);
+ //$orgtables = select($result, $connection2);
if (!$_POST["only_errors"]) {
echo "<form action='' method='post'>\n";
echo "<p>" . ($result->num_rows ? lang('%d row(s)', $result->num_rows) : "") . $time;
@@ -138,15 +139,15 @@
. "<input type='hidden' name='query' value='" . h($q) . "'>"
. " <input type='submit' name='export' value='" . lang('Export') . "' onclick='eventStop(event);'><input type='hidden' name='token' value='$token'></span>\n"
;
- if ($connection2 && preg_match("~^($space|\\()*SELECT\\b~isU", $q) && ($explain = explain($connection2, $q))) {
- $id = "explain";
- echo ", <a href='#$id' onclick=\"return !toggle('$id');\">EXPLAIN</a>$export";
- echo "<div id='$id' class='hidden'>\n";
- select($explain, $connection2, ($jush == "sql" ? "http://dev.mysql.com/doc/refman/" . substr($connection->server_info, 0, 3) . "/en/explain-output.html#explain_" : ""), $orgtables);
- echo "</div>\n";
- } else {
- echo $export;
- }
+ // if ($connection2 && preg_match("~^($space|\\()*SELECT\\b~isU", $q) && ($explain = explain($connection2, $q))) {
+ // $id = "explain";
+ // echo ", <a href='#$id' onclick=\"return !toggle('$id');\">EXPLAIN</a>$export";
+ // echo "<div id='$id' class='hidden'>\n";
+ // select($explain, $connection2, ($jush == "sql" ? "http://dev.mysql.com/doc/refman/" . substr($connection->server_info, 0, 3) . "/en/explain-output.html#explain_" : ""), $orgtables);
+ // echo "</div>\n";
+ // } else {
+ // echo $export;
+ // }
echo "</form>\n";
}
} else {
@@ -177,9 +178,9 @@
echo "<p class='error'>" . lang('Error in query') . ": " . implode("", $errors) . "\n";
}
//! MS SQL - SET SHOWPLAN_ALL OFF
- } else {
- echo "<p class='error'>" . upload_error($query) . "\n";
- }
+ // } else {
+ // echo "<p class='error'>" . upload_error($query) . "\n";
+ // }
}
?>
2 nette
Submodule nette updated from a6b1f7 to 982c94

0 comments on commit f11ccf5

Please sign in to comment.