mirror of
https://github.com/vrana/adminer.git
synced 2025-08-17 20:01:25 +02:00
Doc-comments: Sync method signatures
This commit is contained in:
@@ -25,7 +25,7 @@ if (isset($_GET["mssql"])) {
|
||||
$this->error = rtrim($this->error);
|
||||
}
|
||||
|
||||
function connect($server, $username, $password) {
|
||||
function connect(string $server, string $username, string $password): bool {
|
||||
global $adminer;
|
||||
$connection_info = array("UID" => $username, "PWD" => $password, "CharacterSet" => "UTF-8");
|
||||
$ssl = $adminer->connectSsl();
|
||||
@@ -49,16 +49,16 @@ if (isset($_GET["mssql"])) {
|
||||
return (bool) $this->link;
|
||||
}
|
||||
|
||||
function quote($string) {
|
||||
function quote(string $string): string {
|
||||
$unicode = strlen($string) != strlen(utf8_decode($string));
|
||||
return ($unicode ? "N" : "") . "'" . str_replace("'", "''", $string) . "'";
|
||||
}
|
||||
|
||||
function select_db($database) {
|
||||
function select_db(string $database): bool {
|
||||
return $this->query(use_sql($database));
|
||||
}
|
||||
|
||||
function query($query, $unbuffered = false) {
|
||||
function query(string $query, bool $unbuffered = false) {
|
||||
$result = sqlsrv_query($this->link, $query); //! , array(), ($unbuffered ? array() : array("Scrollable" => "keyset"))
|
||||
$this->error = "";
|
||||
if (!$result) {
|
||||
@@ -68,7 +68,7 @@ if (isset($_GET["mssql"])) {
|
||||
return $this->store_result($result);
|
||||
}
|
||||
|
||||
function multi_query($query) {
|
||||
function multi_query(string $query) {
|
||||
$this->result = sqlsrv_query($this->link, $query);
|
||||
$this->error = "";
|
||||
if (!$this->result) {
|
||||
@@ -92,7 +92,7 @@ if (isset($_GET["mssql"])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function next_result() {
|
||||
function next_result(): bool {
|
||||
return $this->result ? sqlsrv_next_result($this->result) : null;
|
||||
}
|
||||
}
|
||||
@@ -116,15 +116,15 @@ if (isset($_GET["mssql"])) {
|
||||
return $row;
|
||||
}
|
||||
|
||||
function fetch_assoc() {
|
||||
function fetch_assoc(): array {
|
||||
return $this->convert(sqlsrv_fetch_array($this->result, SQLSRV_FETCH_ASSOC));
|
||||
}
|
||||
|
||||
function fetch_row() {
|
||||
function fetch_row(): array {
|
||||
return $this->convert(sqlsrv_fetch_array($this->result, SQLSRV_FETCH_NUMERIC));
|
||||
}
|
||||
|
||||
function fetch_field() {
|
||||
function fetch_field(): object {
|
||||
if (!$this->fields) {
|
||||
$this->fields = sqlsrv_field_metadata($this->result);
|
||||
}
|
||||
@@ -160,7 +160,7 @@ if (isset($_GET["mssql"])) {
|
||||
|
||||
} else {
|
||||
abstract class MssqlDb extends PdoDb {
|
||||
function select_db($database) {
|
||||
function select_db(string $database): bool {
|
||||
// database selection is separated from the connection so dbname in DSN can't be used
|
||||
return $this->query(use_sql($database));
|
||||
}
|
||||
@@ -182,7 +182,7 @@ if (isset($_GET["mssql"])) {
|
||||
class Db extends MssqlDb {
|
||||
public $extension = "PDO_SQLSRV";
|
||||
|
||||
function connect($server, $username, $password) {
|
||||
function connect(string $server, string $username, string $password): bool {
|
||||
$this->dsn("sqlsrv:Server=" . str_replace(":", ",", $server), $username, $password);
|
||||
return true;
|
||||
}
|
||||
@@ -192,7 +192,7 @@ if (isset($_GET["mssql"])) {
|
||||
class Db extends MssqlDb {
|
||||
public $extension = "PDO_DBLIB";
|
||||
|
||||
function connect($server, $username, $password) {
|
||||
function connect(string $server, string $username, string $password): bool {
|
||||
$this->dsn("dblib:charset=utf8;host=" . str_replace(":", ";unix_socket=", preg_replace('~:(\d)~', ';port=\1', $server)), $username, $password);
|
||||
return true;
|
||||
}
|
||||
@@ -220,7 +220,7 @@ if (isset($_GET["mssql"])) {
|
||||
public $onActions = "NO ACTION|CASCADE|SET NULL|SET DEFAULT";
|
||||
public $generated = array("PERSISTED", "VIRTUAL");
|
||||
|
||||
function __construct($connection) {
|
||||
function __construct(Db $connection) {
|
||||
parent::__construct($connection);
|
||||
$this->types = 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),
|
||||
@@ -230,7 +230,7 @@ if (isset($_GET["mssql"])) {
|
||||
);
|
||||
}
|
||||
|
||||
function insertUpdate($table, $rows, $primary) {
|
||||
function insertUpdate(string $table, array $rows, array $primary) {
|
||||
$fields = fields($table);
|
||||
$update = array();
|
||||
$where = array();
|
||||
@@ -274,7 +274,7 @@ if (isset($_GET["mssql"])) {
|
||||
return queries("BEGIN TRANSACTION");
|
||||
}
|
||||
|
||||
function tableHelp($name, $is_view = false) {
|
||||
function tableHelp(string $name, bool $is_view = false) {
|
||||
$links = array(
|
||||
"sys" => "catalog-views/sys-",
|
||||
"INFORMATION_SCHEMA" => "information-schema-views/",
|
||||
|
@@ -54,7 +54,7 @@ if (!defined('Adminer\DRIVER')) {
|
||||
return ($row ? $row[$field] : false);
|
||||
}
|
||||
|
||||
function quote($string) {
|
||||
function quote(string $string): string {
|
||||
return "'" . $this->escape_string($string) . "'";
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ if (!defined('Adminer\DRIVER')) {
|
||||
class Db extends SqlDb {
|
||||
private resource $link;
|
||||
|
||||
function connect($server, $username, $password) {
|
||||
function connect(string $server, string $username, string $password): bool {
|
||||
if (ini_bool("mysql.allow_local_infile")) {
|
||||
$this->error = lang('Disable %s or enable %s or %s extensions.', "'mysql.allow_local_infile'", "MySQLi", "PDO_MySQL");
|
||||
return false;
|
||||
@@ -95,15 +95,15 @@ if (!defined('Adminer\DRIVER')) {
|
||||
return $this->query("SET NAMES $charset");
|
||||
}
|
||||
|
||||
function quote($string) {
|
||||
function quote(string $string): string {
|
||||
return "'" . mysql_real_escape_string($string, $this->link) . "'";
|
||||
}
|
||||
|
||||
function select_db($database) {
|
||||
function select_db(string $database): bool {
|
||||
return mysql_select_db($database, $this->link);
|
||||
}
|
||||
|
||||
function query($query, $unbuffered = false) {
|
||||
function query(string $query, bool $unbuffered = false) {
|
||||
$result = @($unbuffered ? mysql_unbuffered_query($query, $this->link) : mysql_query($query, $this->link)); // @ - mute mysql.trace_mode
|
||||
$this->error = "";
|
||||
if (!$result) {
|
||||
@@ -164,7 +164,7 @@ if (!defined('Adminer\DRIVER')) {
|
||||
class Db extends PdoDb {
|
||||
public $extension = "PDO_MySQL";
|
||||
|
||||
function connect($server, $username, $password) {
|
||||
function connect(string $server, string $username, string $password): bool {
|
||||
global $adminer;
|
||||
$options = array(\PDO::MYSQL_ATTR_LOCAL_INFILE => false);
|
||||
$ssl = $adminer->connectSsl();
|
||||
@@ -195,12 +195,12 @@ if (!defined('Adminer\DRIVER')) {
|
||||
return $this->query("SET NAMES $charset"); // charset in DSN is ignored before PHP 5.3.6
|
||||
}
|
||||
|
||||
function select_db($database) {
|
||||
function select_db(string $database): bool {
|
||||
// database selection is separated from the connection so dbname in DSN can't be used
|
||||
return $this->query("USE " . idf_escape($database));
|
||||
}
|
||||
|
||||
function query($query, $unbuffered = false) {
|
||||
function query(string $query, bool $unbuffered = false) {
|
||||
$this->pdo->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, !$unbuffered);
|
||||
return parent::query($query, $unbuffered);
|
||||
}
|
||||
@@ -219,7 +219,7 @@ if (!defined('Adminer\DRIVER')) {
|
||||
/** @var list<string> */ public array $functions = array("char_length", "date", "from_unixtime", "lower", "round", "floor", "ceil", "sec_to_time", "time_to_sec", "upper");
|
||||
/** @var list<string> */ public array $grouping = array("avg", "count", "count distinct", "group_concat", "max", "min", "sum");
|
||||
|
||||
function __construct($connection) {
|
||||
function __construct(Db $connection) {
|
||||
parent::__construct($connection);
|
||||
$this->types = array(
|
||||
lang('Numbers') => array("tinyint" => 3, "smallint" => 5, "mediumint" => 8, "int" => 10, "bigint" => 20, "decimal" => 66, "float" => 12, "double" => 21),
|
||||
@@ -257,18 +257,18 @@ if (!defined('Adminer\DRIVER')) {
|
||||
}
|
||||
}
|
||||
|
||||
function unconvertFunction($field) {
|
||||
function unconvertFunction(array $field) {
|
||||
return (preg_match("~binary~", $field["type"]) ? "<code class='jush-sql'>UNHEX</code>"
|
||||
: ($field["type"] == "bit" ? doc_link(array('sql' => 'bit-value-literals.html'), "<code>b''</code>")
|
||||
: (preg_match("~geometry|point|linestring|polygon~", $field["type"]) ? "<code class='jush-sql'>GeomFromText</code>"
|
||||
: "")));
|
||||
}
|
||||
|
||||
function insert($table, $set) {
|
||||
function insert(string $table, array $set) {
|
||||
return ($set ? parent::insert($table, $set) : queries("INSERT INTO " . table($table) . " ()\nVALUES ()"));
|
||||
}
|
||||
|
||||
function insertUpdate($table, $rows, $primary) {
|
||||
function insertUpdate(string $table, array $rows, array $primary) {
|
||||
$columns = array_keys(reset($rows));
|
||||
$prefix = "INSERT INTO " . table($table) . " (" . implode(", ", $columns) . ") VALUES\n";
|
||||
$values = array();
|
||||
@@ -293,7 +293,7 @@ if (!defined('Adminer\DRIVER')) {
|
||||
return queries($prefix . implode(",\n", $values) . $suffix);
|
||||
}
|
||||
|
||||
function slowQuery($query, $timeout) {
|
||||
function slowQuery(string $query, int $timeout) {
|
||||
if (min_version('5.7.8', '10.1.2')) {
|
||||
if ($this->conn->flavor == 'maria') {
|
||||
return "SET STATEMENT max_statement_time=$timeout FOR $query";
|
||||
@@ -303,7 +303,7 @@ if (!defined('Adminer\DRIVER')) {
|
||||
}
|
||||
}
|
||||
|
||||
function convertSearch($idf, $val, $field) {
|
||||
function convertSearch(string $idf, array $val, array $field): string {
|
||||
return (preg_match('~char|text|enum|set~', $field["type"]) && !preg_match("~^utf8~", $field["collation"]) && preg_match('~[\x80-\xFF]~', $val['val'])
|
||||
? "CONVERT($idf USING " . charset($this->conn) . ")"
|
||||
: $idf
|
||||
@@ -319,7 +319,7 @@ if (!defined('Adminer\DRIVER')) {
|
||||
}
|
||||
}
|
||||
|
||||
function tableHelp($name, $is_view = false) {
|
||||
function tableHelp(string $name, bool $is_view = false) {
|
||||
$maria = ($this->conn->flavor == 'maria');
|
||||
if (information_schema(DB)) {
|
||||
return strtolower("information-schema-" . ($maria ? "$name-table/" : str_replace("_", "-", $name) . "-table.html"));
|
||||
@@ -329,7 +329,7 @@ if (!defined('Adminer\DRIVER')) {
|
||||
}
|
||||
}
|
||||
|
||||
function hasCStyleEscapes() {
|
||||
function hasCStyleEscapes(): bool {
|
||||
static $c_style;
|
||||
if ($c_style === null) {
|
||||
$sql_mode = $this->conn->result("SHOW VARIABLES LIKE 'sql_mode'", 1);
|
||||
@@ -338,7 +338,7 @@ if (!defined('Adminer\DRIVER')) {
|
||||
return $c_style;
|
||||
}
|
||||
|
||||
function engines() {
|
||||
function engines(): array {
|
||||
$return = array();
|
||||
foreach (get_rows("SHOW ENGINES") as $row) {
|
||||
if (preg_match("~YES|DEFAULT~", $row["Support"])) {
|
||||
|
@@ -19,7 +19,7 @@ if (isset($_GET["oracle"])) {
|
||||
$this->error = $error;
|
||||
}
|
||||
|
||||
function connect($server, $username, $password) {
|
||||
function connect(string $server, string $username, string $password): bool {
|
||||
$this->link = @oci_new_connect($username, $password, $server, "AL32UTF8");
|
||||
if ($this->link) {
|
||||
$this->server_info = oci_server_version($this->link);
|
||||
@@ -30,16 +30,16 @@ if (isset($_GET["oracle"])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function quote($string) {
|
||||
function quote(string $string): string {
|
||||
return "'" . str_replace("'", "''", $string) . "'";
|
||||
}
|
||||
|
||||
function select_db($database) {
|
||||
function select_db(string $database): bool {
|
||||
$this->_current_db = $database;
|
||||
return true;
|
||||
}
|
||||
|
||||
function query($query, $unbuffered = false) {
|
||||
function query(string $query, bool $unbuffered = false) {
|
||||
$result = oci_parse($this->link, $query);
|
||||
$this->error = "";
|
||||
if (!$result) {
|
||||
@@ -79,15 +79,15 @@ if (isset($_GET["oracle"])) {
|
||||
return $row;
|
||||
}
|
||||
|
||||
function fetch_assoc() {
|
||||
function fetch_assoc(): array {
|
||||
return $this->convert(oci_fetch_assoc($this->result));
|
||||
}
|
||||
|
||||
function fetch_row() {
|
||||
function fetch_row(): array {
|
||||
return $this->convert(oci_fetch_row($this->result));
|
||||
}
|
||||
|
||||
function fetch_field() {
|
||||
function fetch_field(): object {
|
||||
$column = $this->offset++;
|
||||
$return = new \stdClass;
|
||||
$return->name = oci_field_name($this->result, $column);
|
||||
@@ -106,12 +106,12 @@ if (isset($_GET["oracle"])) {
|
||||
public $extension = "PDO_OCI";
|
||||
public $_current_db;
|
||||
|
||||
function connect($server, $username, $password) {
|
||||
function connect(string $server, string $username, string $password): bool {
|
||||
$this->dsn("oci:dbname=//$server;charset=AL32UTF8", $username, $password);
|
||||
return true;
|
||||
}
|
||||
|
||||
function select_db($database) {
|
||||
function select_db(string $database): bool {
|
||||
$this->_current_db = $database;
|
||||
return true;
|
||||
}
|
||||
@@ -140,7 +140,7 @@ if (isset($_GET["oracle"])) {
|
||||
public $functions = array("length", "lower", "round", "upper");
|
||||
public $grouping = array("avg", "count", "count distinct", "max", "min", "sum");
|
||||
|
||||
function __construct($connection) {
|
||||
function __construct(Db $connection) {
|
||||
parent::__construct($connection);
|
||||
$this->types = array(
|
||||
lang('Numbers') => array("number" => 38, "binary_float" => 12, "binary_double" => 21),
|
||||
@@ -156,7 +156,7 @@ if (isset($_GET["oracle"])) {
|
||||
return true; // automatic start
|
||||
}
|
||||
|
||||
function insertUpdate($table, $rows, $primary) {
|
||||
function insertUpdate(string $table, array $rows, array $primary) {
|
||||
global $connection;
|
||||
foreach ($rows as $set) {
|
||||
$update = array();
|
||||
@@ -177,7 +177,7 @@ if (isset($_GET["oracle"])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function hasCStyleEscapes() {
|
||||
function hasCStyleEscapes(): bool {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ if (isset($_GET["pgsql"])) {
|
||||
$this->error = $error;
|
||||
}
|
||||
|
||||
function connect($server, $username, $password) {
|
||||
function connect(string $server, string $username, string $password): bool {
|
||||
global $adminer;
|
||||
$db = $adminer->database();
|
||||
set_error_handler(array($this, '_error'));
|
||||
@@ -40,18 +40,18 @@ if (isset($_GET["pgsql"])) {
|
||||
return (bool) $this->link;
|
||||
}
|
||||
|
||||
function quote($string) {
|
||||
function quote(string $string): string {
|
||||
return (function_exists('pg_escape_literal')
|
||||
? pg_escape_literal($this->link, $string) // available since PHP 5.4.4
|
||||
: "'" . pg_escape_string($this->link, $string) . "'"
|
||||
);
|
||||
}
|
||||
|
||||
function value($val, $field) {
|
||||
function value(string $val, array $field): string {
|
||||
return ($field["type"] == "bytea" && $val !== null ? pg_unescape_bytea($val) : $val);
|
||||
}
|
||||
|
||||
function select_db($database) {
|
||||
function select_db(string $database): bool {
|
||||
global $adminer;
|
||||
if ($database == $adminer->database()) {
|
||||
return $this->database;
|
||||
@@ -67,7 +67,7 @@ if (isset($_GET["pgsql"])) {
|
||||
$this->link = @pg_connect("$this->string dbname='postgres'");
|
||||
}
|
||||
|
||||
function query($query, $unbuffered = false) {
|
||||
function query(string $query, bool $unbuffered = false) {
|
||||
$result = @pg_query($this->link, $query);
|
||||
$this->error = "";
|
||||
if (!$result) {
|
||||
@@ -100,15 +100,15 @@ if (isset($_GET["pgsql"])) {
|
||||
$this->num_rows = pg_num_rows($result);
|
||||
}
|
||||
|
||||
function fetch_assoc() {
|
||||
function fetch_assoc(): array {
|
||||
return pg_fetch_assoc($this->result);
|
||||
}
|
||||
|
||||
function fetch_row() {
|
||||
function fetch_row(): array {
|
||||
return pg_fetch_row($this->result);
|
||||
}
|
||||
|
||||
function fetch_field() {
|
||||
function fetch_field(): object {
|
||||
$column = $this->offset++;
|
||||
$return = new \stdClass;
|
||||
$return->orgtable = pg_field_table($this->result, $column);
|
||||
@@ -127,7 +127,7 @@ if (isset($_GET["pgsql"])) {
|
||||
class Db extends PdoDb {
|
||||
public $extension = "PDO_PgSQL", $timeout;
|
||||
|
||||
function connect($server, $username, $password) {
|
||||
function connect(string $server, string $username, string $password): bool {
|
||||
global $adminer;
|
||||
$db = $adminer->database();
|
||||
//! client_encoding is supported since 9.1, but we can't yet use min_version here
|
||||
@@ -140,12 +140,12 @@ if (isset($_GET["pgsql"])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function select_db($database) {
|
||||
function select_db(string $database): bool {
|
||||
global $adminer;
|
||||
return ($adminer->database() == $database);
|
||||
}
|
||||
|
||||
function query($query, $unbuffered = false) {
|
||||
function query(string $query, bool $unbuffered = false) {
|
||||
$return = parent::query($query, $unbuffered);
|
||||
if ($this->timeout) {
|
||||
$this->timeout = 0;
|
||||
@@ -174,7 +174,7 @@ if (isset($_GET["pgsql"])) {
|
||||
public $functions = array("char_length", "lower", "round", "to_hex", "to_timestamp", "upper");
|
||||
public $grouping = array("avg", "count", "count distinct", "max", "min", "sum");
|
||||
|
||||
function __construct($connection) {
|
||||
function __construct(Db $connection) {
|
||||
parent::__construct($connection);
|
||||
$this->types = array( //! arrays
|
||||
lang('Numbers') => array("smallint" => 5, "integer" => 10, "bigint" => 19, "boolean" => 1, "numeric" => 0, "real" => 7, "double precision" => 16, "money" => 20),
|
||||
@@ -205,7 +205,7 @@ if (isset($_GET["pgsql"])) {
|
||||
}
|
||||
}
|
||||
|
||||
function enumLength($field) {
|
||||
function enumLength(array $field) {
|
||||
$enum = $this->types[lang('User types')][$field["type"]];
|
||||
return ($enum ? type_values($enum) : "");
|
||||
}
|
||||
@@ -214,14 +214,14 @@ if (isset($_GET["pgsql"])) {
|
||||
$this->types[lang('User types')] = array_flip($types);
|
||||
}
|
||||
|
||||
function insertReturning($table) {
|
||||
function insertReturning(string $table): string {
|
||||
$auto_increment = array_filter(fields($table), function ($field) {
|
||||
return $field['auto_increment'];
|
||||
});
|
||||
return (count($auto_increment) == 1 ? " RETURNING " . idf_escape(key($auto_increment)) : "");
|
||||
}
|
||||
|
||||
function insertUpdate($table, $rows, $primary) {
|
||||
function insertUpdate(string $table, array $rows, array $primary) {
|
||||
global $connection;
|
||||
foreach ($rows as $set) {
|
||||
$update = array();
|
||||
@@ -242,13 +242,13 @@ if (isset($_GET["pgsql"])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function slowQuery($query, $timeout) {
|
||||
function slowQuery(string $query, int $timeout) {
|
||||
$this->conn->query("SET statement_timeout = " . (1000 * $timeout));
|
||||
$this->conn->timeout = 1000 * $timeout;
|
||||
return $query;
|
||||
}
|
||||
|
||||
function convertSearch($idf, $val, $field) {
|
||||
function convertSearch(string $idf, array $val, array $field): string {
|
||||
$textTypes = "char|text";
|
||||
if (strpos($val["op"], "LIKE") === false) {
|
||||
$textTypes .= "|date|time(stamp)?|boolean|uuid|inet|cidr|macaddr|" . number_type();
|
||||
@@ -257,7 +257,7 @@ if (isset($_GET["pgsql"])) {
|
||||
return (preg_match("~$textTypes~", $field["type"]) ? $idf : "CAST($idf AS text)");
|
||||
}
|
||||
|
||||
function quoteBinary($s) {
|
||||
function quoteBinary(string $s): string {
|
||||
return "'\\x" . bin2hex($s) . "'"; // available since PostgreSQL 8.1
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ if (isset($_GET["pgsql"])) {
|
||||
return $this->conn->warnings();
|
||||
}
|
||||
|
||||
function tableHelp($name, $is_view = false) {
|
||||
function tableHelp(string $name, bool $is_view = false) {
|
||||
$links = array(
|
||||
"information_schema" => "infoschema",
|
||||
"pg_catalog" => ($is_view ? "view" : "catalog"),
|
||||
@@ -276,12 +276,12 @@ if (isset($_GET["pgsql"])) {
|
||||
}
|
||||
}
|
||||
|
||||
function supportsIndex($table_status) {
|
||||
function supportsIndex(array $table_status): bool {
|
||||
// returns true for "materialized view"
|
||||
return $table_status["Engine"] != "view";
|
||||
}
|
||||
|
||||
function hasCStyleEscapes() {
|
||||
function hasCStyleEscapes(): bool {
|
||||
static $c_style;
|
||||
if ($c_style === null) {
|
||||
$c_style = ($this->conn->result("SHOW standard_conforming_strings") == "off");
|
||||
@@ -772,7 +772,7 @@ ORDER BY SPECIFIC_NAME');
|
||||
}
|
||||
}
|
||||
|
||||
function types() {
|
||||
function types(): array {
|
||||
return get_key_vals(
|
||||
"SELECT oid, typname
|
||||
FROM pg_type
|
||||
|
@@ -11,14 +11,14 @@ if (isset($_GET["sqlite"])) {
|
||||
public $extension = "SQLite3";
|
||||
private $link;
|
||||
|
||||
function connect($filename, $username = '', $password = '') {
|
||||
function connect(string $filename, string $username = '', string $password = ''): bool {
|
||||
$this->link = new \SQLite3($filename);
|
||||
$version = $this->link->version();
|
||||
$this->server_info = $version["versionString"];
|
||||
return true;
|
||||
}
|
||||
|
||||
function query($query, $unbuffered = false) {
|
||||
function query(string $query, bool $unbuffered = false) {
|
||||
$result = @$this->link->query($query);
|
||||
$this->error = "";
|
||||
if (!$result) {
|
||||
@@ -32,7 +32,7 @@ if (isset($_GET["sqlite"])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function quote($string) {
|
||||
function quote(string $string): string {
|
||||
return (is_utf8($string)
|
||||
? "'" . $this->link->escapeString($string) . "'"
|
||||
: "x'" . first(unpack('H*', $string)) . "'"
|
||||
@@ -48,15 +48,15 @@ if (isset($_GET["sqlite"])) {
|
||||
$this->result = $result;
|
||||
}
|
||||
|
||||
function fetch_assoc() {
|
||||
function fetch_assoc(): array {
|
||||
return $this->result->fetchArray(SQLITE3_ASSOC);
|
||||
}
|
||||
|
||||
function fetch_row() {
|
||||
function fetch_row(): array {
|
||||
return $this->result->fetchArray(SQLITE3_NUM);
|
||||
}
|
||||
|
||||
function fetch_field() {
|
||||
function fetch_field(): object {
|
||||
$column = $this->offset++;
|
||||
$type = $this->result->columnType($column);
|
||||
return (object) array(
|
||||
@@ -75,7 +75,7 @@ if (isset($_GET["sqlite"])) {
|
||||
abstract class SqliteDb extends PdoDb {
|
||||
public $extension = "PDO_SQLite";
|
||||
|
||||
function connect($filename, $username = '', $password = '') {
|
||||
function connect(string $filename, string $username = '', string $password = ''): bool {
|
||||
$this->dsn(DRIVER . ":$filename", "", "");
|
||||
$this->query("PRAGMA foreign_keys = 1");
|
||||
$this->query("PRAGMA busy_timeout = 500");
|
||||
@@ -87,14 +87,14 @@ if (isset($_GET["sqlite"])) {
|
||||
|
||||
if (class_exists('Adminer\SqliteDb')) {
|
||||
class Db extends SqliteDb {
|
||||
function connect($filename, $username = '', $password = '') {
|
||||
function connect(string $filename, string $username = '', string $password = ''): bool {
|
||||
parent::connect($filename);
|
||||
$this->query("PRAGMA foreign_keys = 1");
|
||||
$this->query("PRAGMA busy_timeout = 500");
|
||||
return true;
|
||||
}
|
||||
|
||||
function select_db($filename) {
|
||||
function select_db(string $filename): bool {
|
||||
if (is_readable($filename) && $this->query("ATTACH " . $this->quote(preg_match("~(^[/\\\\]|:)~", $filename) ? $filename : dirname($_SERVER["SCRIPT_FILENAME"]) . "/$filename") . " AS a")) {
|
||||
return self::connect($filename);
|
||||
}
|
||||
@@ -125,18 +125,18 @@ if (isset($_GET["sqlite"])) {
|
||||
public $functions = array("hex", "length", "lower", "round", "unixepoch", "upper");
|
||||
public $grouping = array("avg", "count", "count distinct", "group_concat", "max", "min", "sum");
|
||||
|
||||
function __construct($connection) {
|
||||
function __construct(Db $connection) {
|
||||
parent::__construct($connection);
|
||||
if (min_version(3.31, 0, $connection)) {
|
||||
$this->generated = array("STORED", "VIRTUAL");
|
||||
}
|
||||
}
|
||||
|
||||
function structuredTypes() {
|
||||
function structuredTypes(): array {
|
||||
return array_keys($this->types[0]);
|
||||
}
|
||||
|
||||
function insertUpdate($table, $rows, $primary) {
|
||||
function insertUpdate(string $table, array $rows, array $primary) {
|
||||
$values = array();
|
||||
foreach ($rows as $set) {
|
||||
$values[] = "(" . implode(", ", $set) . ")";
|
||||
@@ -144,7 +144,7 @@ if (isset($_GET["sqlite"])) {
|
||||
return queries("REPLACE INTO " . table($table) . " (" . implode(", ", array_keys(reset($rows))) . ") VALUES\n" . implode(",\n", $values));
|
||||
}
|
||||
|
||||
function tableHelp($name, $is_view = false) {
|
||||
function tableHelp(string $name, bool $is_view = false) {
|
||||
if ($name == "sqlite_sequence") {
|
||||
return "fileformat2.html#seqtab";
|
||||
}
|
||||
@@ -153,7 +153,7 @@ if (isset($_GET["sqlite"])) {
|
||||
}
|
||||
}
|
||||
|
||||
function checkConstraints($table) {
|
||||
function checkConstraints(string $table): array {
|
||||
preg_match_all('~ CHECK *(\( *(((?>[^()]*[^() ])|(?1))*) *\))~', $this->conn->result("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = " . q($table)), $matches); //! could be inside a comment
|
||||
return array_combine($matches[2], $matches[2]);
|
||||
}
|
||||
@@ -667,7 +667,7 @@ if (isset($_GET["sqlite"])) {
|
||||
function found_rows($table_status, $where) {
|
||||
}
|
||||
|
||||
function types() {
|
||||
function types(): array {
|
||||
return array();
|
||||
}
|
||||
|
||||
|
@@ -46,7 +46,7 @@ abstract class SqlDriver {
|
||||
/** Get structured types
|
||||
* @return list<string>[]|list<string> [$description => [$type, ...], ...]
|
||||
*/
|
||||
function structuredTypes() {
|
||||
function structuredTypes(): array {
|
||||
return array_map('array_keys', $this->types);
|
||||
}
|
||||
|
||||
|
@@ -20,11 +20,11 @@ if (extension_loaded('pdo')) {
|
||||
$this->server_info = @$this->pdo->getAttribute(\PDO::ATTR_SERVER_VERSION);
|
||||
}
|
||||
|
||||
function quote($string) {
|
||||
function quote(string $string): string {
|
||||
return $this->pdo->quote($string);
|
||||
}
|
||||
|
||||
function query($query, $unbuffered = false) {
|
||||
function query(string $query, bool $unbuffered = false) {
|
||||
/** @var Result|bool */
|
||||
$result = $this->pdo->query($query);
|
||||
$this->error = "";
|
||||
@@ -54,7 +54,7 @@ if (extension_loaded('pdo')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function next_result() {
|
||||
function next_result(): bool {
|
||||
/** @var PdoResult|bool */
|
||||
$result = $this->multi;
|
||||
if (!is_object($result)) {
|
||||
@@ -68,15 +68,15 @@ if (extension_loaded('pdo')) {
|
||||
class PdoResult extends \PDOStatement {
|
||||
public $_offset = 0, $num_rows;
|
||||
|
||||
function fetch_assoc() {
|
||||
function fetch_assoc(): array {
|
||||
return $this->fetch(\PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
function fetch_row() {
|
||||
function fetch_row(): array {
|
||||
return $this->fetch(\PDO::FETCH_NUM);
|
||||
}
|
||||
|
||||
function fetch_field() {
|
||||
function fetch_field(): object {
|
||||
$row = (object) $this->getColumnMeta($this->_offset++);
|
||||
$type = $row->pdo_type;
|
||||
$row->type = ($type == \PDO::PARAM_INT ? 0 : 15);
|
||||
|
Reference in New Issue
Block a user