SQLite variables
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1467 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
parent
3f5b683456
commit
984d0907c8
|
@ -666,6 +666,14 @@ if (!defined("DRIVER")) {
|
||||||
return $connection->result("SHOW CREATE TABLE " . idf_escape($table), 1);
|
return $connection->result("SHOW CREATE TABLE " . idf_escape($table), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function show_variables() {
|
||||||
|
return get_key_vals("SHOW VARIABLES");
|
||||||
|
}
|
||||||
|
|
||||||
|
function show_status() {
|
||||||
|
return get_key_vals("SHOW STATUS");
|
||||||
|
}
|
||||||
|
|
||||||
/** Check whether a feature is supported
|
/** Check whether a feature is supported
|
||||||
* @param string
|
* @param string
|
||||||
* @return bool
|
* @return bool
|
||||||
|
|
|
@ -44,7 +44,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
|
|
||||||
function result($query, $field = 0) {
|
function result($query, $field = 0) {
|
||||||
$result = $this->query($query);
|
$result = $this->query($query);
|
||||||
if (!$result) {
|
if (!is_object($result)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$row = $result->_result->fetch();
|
$row = $result->_result->fetch();
|
||||||
|
@ -89,37 +89,38 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
class Min_SQLite extends SQLite3 {
|
class Min_SQLite {
|
||||||
var $extension = "SQLite3", $server_info, $affected_rows, $error;
|
var $extension = "SQLite3", $server_info, $affected_rows, $error, $_connection;
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
$version = $this->version();
|
$this->_connection = new SQLite3(":memory:"); // required to display variables
|
||||||
|
$version = $this->_connection->version();
|
||||||
$this->server_info = $version["versionString"];
|
$this->server_info = $version["versionString"];
|
||||||
}
|
}
|
||||||
|
|
||||||
function open($filename) {
|
function open($filename) {
|
||||||
parent::__construct($filename);
|
$this->_connection->open($filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
function query($query) {
|
function query($query) {
|
||||||
$result = @parent::query($query);
|
$result = @$this->_connection->query($query);
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
$this->error = $this->lastErrorMsg();
|
$this->error = $this->_connection->lastErrorMsg();
|
||||||
return false;
|
return false;
|
||||||
} elseif ($result->numColumns()) {
|
} elseif ($result->numColumns()) {
|
||||||
return new Min_Result($result);
|
return new Min_Result($result);
|
||||||
}
|
}
|
||||||
$this->affected_rows = $this->changes();
|
$this->affected_rows = $this->_connection->changes();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function quote($string) {
|
function quote($string) {
|
||||||
return "'" . $this->escapeString($string) . "'";
|
return "'" . $this->_connection->escapeString($string) . "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
function result($query, $field = 0) {
|
function result($query, $field = 0) {
|
||||||
$result = $this->query($query);
|
$result = $this->query($query);
|
||||||
if (!$result) {
|
if (!is_object($result)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$row = $result->_result->fetchArray();
|
$row = $result->_result->fetchArray();
|
||||||
|
@ -254,6 +255,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
$return = array();
|
$return = array();
|
||||||
$result = $connection->query("SELECT name AS Name, type AS Engine FROM sqlite_master WHERE type IN ('table', 'view')" . ($name != "" ? " AND name = " . $connection->quote($name) : ""));
|
$result = $connection->query("SELECT name AS Name, type AS Engine FROM sqlite_master WHERE type IN ('table', 'view')" . ($name != "" ? " AND name = " . $connection->quote($name) : ""));
|
||||||
while ($row = $result->fetch_assoc()) {
|
while ($row = $result->fetch_assoc()) {
|
||||||
|
$row["Auto_increment"] = "";
|
||||||
$return[$row["Name"]] = $row;
|
$return[$row["Name"]] = $row;
|
||||||
}
|
}
|
||||||
$result = $connection->query("SELECT * FROM sqlite_sequence");
|
$result = $connection->query("SELECT * FROM sqlite_sequence");
|
||||||
|
@ -456,8 +458,21 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
return $connection->result("SELECT sql FROM sqlite_master WHERE name = " . $connection->quote($table));
|
return $connection->result("SELECT sql FROM sqlite_master WHERE name = " . $connection->quote($table));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function show_variables() {
|
||||||
|
global $connection;
|
||||||
|
$return = array();
|
||||||
|
foreach (array("auto_vacuum", "cache_size", "count_changes", "default_cache_size", "empty_result_callbacks", "encoding", "foreign_keys", "full_column_names", "fullfsync", "journal_mode", "journal_size_limit", "legacy_file_format", "locking_mode", "page_size", "max_page_count", "read_uncommitted", "recursive_triggers", "reverse_unordered_selects", "secure_delete", "short_column_names", "synchronous", "temp_store", "temp_store_directory", "schema_version", "compile_options", "integrity_check", "quick_check") as $key) {
|
||||||
|
$return[$key] = $connection->result("PRAGMA $key");
|
||||||
|
}
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
function show_status() {
|
||||||
|
// not supported
|
||||||
|
}
|
||||||
|
|
||||||
function support($feature) {
|
function support($feature) {
|
||||||
return ereg('^(view|trigger)$', $feature);
|
return ereg('^(view|trigger|variables)$', $feature);
|
||||||
}
|
}
|
||||||
|
|
||||||
$driver = "sqlite";
|
$driver = "sqlite";
|
||||||
|
|
|
@ -55,7 +55,7 @@ function select($result, $connection2 = null) {
|
||||||
} else {
|
} else {
|
||||||
if ($blobs[$key] && !is_utf8($val)) {
|
if ($blobs[$key] && !is_utf8($val)) {
|
||||||
$val = "<i>" . lang('%d byte(s)', strlen($val)) . "</i>"; //! link to download
|
$val = "<i>" . lang('%d byte(s)', strlen($val)) . "</i>"; //! link to download
|
||||||
} elseif ($val == "") {
|
} elseif (!strlen($val)) { // strlen - SQLite can return int
|
||||||
$val = " "; // some content to print a border
|
$val = " "; // some content to print a border
|
||||||
} else {
|
} else {
|
||||||
$val = h($val);
|
$val = h($val);
|
||||||
|
|
|
@ -2,11 +2,10 @@
|
||||||
$status = isset($_GET["status"]);
|
$status = isset($_GET["status"]);
|
||||||
page_header($status ? lang('Status') : lang('Variables'));
|
page_header($status ? lang('Status') : lang('Variables'));
|
||||||
|
|
||||||
$result = $connection->query($status ? "SHOW STATUS" : "SHOW VARIABLES");
|
|
||||||
echo "<table cellspacing='0'>\n";
|
echo "<table cellspacing='0'>\n";
|
||||||
while ($row = $result->fetch_assoc()) {
|
foreach (($status ? show_status() : show_variables()) as $key => $val) {
|
||||||
echo "<tr>";
|
echo "<tr>";
|
||||||
echo "<th><code class='jush-" . ($status ? "sqlstatus" : "sqlset") . "'>" . h($row["Variable_name"]) . "</code>";
|
echo "<th><code class='jush-" . $driver . ($status ? "status" : "set") . "'>" . h($key) . "</code>";
|
||||||
echo "<td>" . nbsp($row["Value"]);
|
echo "<td>" . nbsp($val);
|
||||||
}
|
}
|
||||||
echo "</table>\n";
|
echo "</table>\n";
|
||||||
|
|
Loading…
Reference in a new issue