mirror of
https://github.com/vrana/adminer.git
synced 2025-08-08 07:36:44 +02:00
Use common parent for Db
This commit is contained in:
@@ -7,10 +7,10 @@ if (isset($_GET["clickhouse"])) {
|
||||
define('Adminer\DRIVER', "clickhouse");
|
||||
|
||||
if (ini_bool('allow_url_fopen')) {
|
||||
class Db {
|
||||
public $extension = "JSON", $flavor = '', $server_info, $errno, $error;
|
||||
class Db extends SqlDb {
|
||||
public $extension = "JSON";
|
||||
public $_db = 'default';
|
||||
private $result, $url;
|
||||
private $url;
|
||||
|
||||
function rootQuery($db, $query) {
|
||||
$file = @file_get_contents("$this->url/?database=$db", false, stream_context_create(array('http' => array(
|
||||
@@ -52,7 +52,7 @@ if (isset($_GET["clickhouse"])) {
|
||||
return (bool) preg_match('~^(select|show)~i', $query);
|
||||
}
|
||||
|
||||
function query($query) {
|
||||
function query($query, $unbuffered = false) {
|
||||
return $this->rootQuery($this->_db, $query);
|
||||
}
|
||||
|
||||
@@ -71,23 +71,6 @@ if (isset($_GET["clickhouse"])) {
|
||||
function quote($string) {
|
||||
return "'" . addcslashes($string, "\\'") . "'";
|
||||
}
|
||||
|
||||
function multi_query($query) {
|
||||
return $this->result = $this->query($query);
|
||||
}
|
||||
|
||||
function store_result() {
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
function next_result() {
|
||||
return false;
|
||||
}
|
||||
|
||||
function result($query, $field = 0) {
|
||||
$result = $this->query($query);
|
||||
return $result['data'];
|
||||
}
|
||||
}
|
||||
|
||||
class Result {
|
||||
|
@@ -8,8 +8,8 @@ if (isset($_GET["elastic"])) {
|
||||
|
||||
if (ini_bool('allow_url_fopen')) {
|
||||
|
||||
class Db {
|
||||
public $extension = "JSON", $flavor = '', $server_info, $errno, $error;
|
||||
class Db extends SqlDb {
|
||||
public $extension = "JSON";
|
||||
private $url;
|
||||
|
||||
/**
|
||||
@@ -65,7 +65,7 @@ if (isset($_GET["elastic"])) {
|
||||
|
||||
$where = explode(" AND ", $matches[2]);
|
||||
|
||||
return $driver->select($matches[1], array("*"), $where, null, array(), $matches[3]);
|
||||
return $driver->select($matches[1], array("*"), $where, array(), array(), $matches[3]);
|
||||
}
|
||||
|
||||
return $this->rootQuery($path, $content, $method);
|
||||
|
@@ -11,17 +11,8 @@ if (isset($_GET["firebird"])) {
|
||||
define('Adminer\DRIVER', "firebird");
|
||||
|
||||
if (extension_loaded("interbase")) {
|
||||
class Db {
|
||||
public
|
||||
$extension = "Firebird",
|
||||
$flavor = '',
|
||||
$server_info,
|
||||
$affected_rows,
|
||||
$errno,
|
||||
$error,
|
||||
$_link
|
||||
;
|
||||
private $result;
|
||||
class Db extends SqlDb {
|
||||
public $extension = "Firebird", $_link;
|
||||
|
||||
function connect($server, $username, $password) {
|
||||
$this->_link = ibase_connect($server, $username, $password);
|
||||
@@ -45,7 +36,7 @@ if (isset($_GET["firebird"])) {
|
||||
}
|
||||
|
||||
function query($query, $unbuffered = false) {
|
||||
$result = ibase_query($query, $this->_link);
|
||||
$result = ibase_query($this->_link, $query);
|
||||
if (!$result) {
|
||||
$this->errno = ibase_errcode();
|
||||
$this->error = ibase_errmsg();
|
||||
@@ -58,27 +49,6 @@ if (isset($_GET["firebird"])) {
|
||||
}
|
||||
return new Result($result);
|
||||
}
|
||||
|
||||
function multi_query($query) {
|
||||
return $this->result = $this->query($query);
|
||||
}
|
||||
|
||||
function store_result() {
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
function next_result() {
|
||||
return false;
|
||||
}
|
||||
|
||||
function result($query, $field = 0) {
|
||||
$result = $this->query($query);
|
||||
if (!$result || !$result->num_rows) {
|
||||
return false;
|
||||
}
|
||||
$row = $result->fetch_row();
|
||||
return $row[$field];
|
||||
}
|
||||
}
|
||||
|
||||
class Result {
|
||||
|
@@ -18,10 +18,8 @@ if (isset($_GET["imap"])) {
|
||||
define('Adminer\DRIVER', "imap");
|
||||
|
||||
if (extension_loaded("imap")) {
|
||||
class Db {
|
||||
class Db extends SqlDb {
|
||||
public $extension = "IMAP";
|
||||
public $flavor = '';
|
||||
public $error;
|
||||
public $server_info = "?"; // imap_mailboxmsginfo() or imap_check() don't return anything useful
|
||||
private $mailbox;
|
||||
private $imap;
|
||||
|
@@ -7,8 +7,8 @@ if (isset($_GET["mongo"])) {
|
||||
define('Adminer\DRIVER', "mongo");
|
||||
|
||||
if (class_exists('MongoDB\Driver\Manager')) {
|
||||
class Db {
|
||||
public $extension = "MongoDB", $flavor = '', $server_info = MONGODB_VERSION, $affected_rows, $error, $last_id;
|
||||
class Db extends SqlDb {
|
||||
public $extension = "MongoDB", $server_info = MONGODB_VERSION, $last_id;
|
||||
/** @var \MongoDB\Driver\Manager */
|
||||
public $_link;
|
||||
public $_db, $_db_name;
|
||||
@@ -42,7 +42,7 @@ if (isset($_GET["mongo"])) {
|
||||
}
|
||||
}
|
||||
|
||||
function query($query) {
|
||||
function query($query, $unbuffered = false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ if (isset($_GET["mongo"])) {
|
||||
$driver = driver();
|
||||
$fields = fields_from_edit();
|
||||
if (!$fields) {
|
||||
$result = $driver->select($table, array("*"), null, null, array(), 10);
|
||||
$result = $driver->select($table, array("*"), array(), array(), array(), 10);
|
||||
if ($result) {
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
foreach ($row as $key => $val) {
|
||||
|
@@ -7,9 +7,8 @@ if (isset($_GET["simpledb"])) {
|
||||
define('Adminer\DRIVER', "simpledb");
|
||||
|
||||
if (class_exists('SimpleXMLElement') && ini_bool('allow_url_fopen')) {
|
||||
class Db {
|
||||
public $extension = "SimpleXML", $flavor = '', $server_info = '2009-04-15', $error, $timeout, $next, $affected_rows;
|
||||
private $result;
|
||||
class Db extends SqlDb {
|
||||
public $extension = "SimpleXML", $server_info = '2009-04-15', $timeout, $next;
|
||||
|
||||
function select_db($database) {
|
||||
return ($database == "domain");
|
||||
@@ -38,18 +37,6 @@ if (isset($_GET["simpledb"])) {
|
||||
return new Result($result);
|
||||
}
|
||||
|
||||
function multi_query($query) {
|
||||
return $this->result = $this->query($query);
|
||||
}
|
||||
|
||||
function store_result() {
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
function next_result() {
|
||||
return false;
|
||||
}
|
||||
|
||||
function quote($string) {
|
||||
return "'" . str_replace("'", "''", $string) . "'";
|
||||
}
|
||||
|
Reference in New Issue
Block a user