diff --git a/adminer/drivers/mongo.inc.php b/adminer/drivers/mongo.inc.php index d61365d6..a400c2e1 100644 --- a/adminer/drivers/mongo.inc.php +++ b/adminer/drivers/mongo.inc.php @@ -53,14 +53,15 @@ if (isset($_GET["mongo"])) { } class Result { - var $num_rows, $_rows = array(), $_offset = 0, $_charset = array(); + var $num_rows; + private $rows = array(), $offset = 0, $charset = array(); function __construct($result) { foreach ($result as $item) { $row = array(); foreach ($item as $key => $val) { if (is_a($val, 'MongoDB\BSON\Binary')) { - $this->_charset[$key] = 63; + $this->charset[$key] = 63; } $row[$key] = (is_a($val, 'MongoDB\BSON\ObjectID') ? 'MongoDB\BSON\ObjectID("' . "$val\")" : @@ -71,26 +72,26 @@ if (isset($_GET["mongo"])) { $val // MongoMinKey, MongoMaxKey ))))); } - $this->_rows[] = $row; + $this->rows[] = $row; foreach ($row as $key => $val) { - if (!isset($this->_rows[0][$key])) { - $this->_rows[0][$key] = null; + if (!isset($this->rows[0][$key])) { + $this->rows[0][$key] = null; } } } - $this->num_rows = count($this->_rows); + $this->num_rows = count($this->rows); } function fetch_assoc() { - $row = current($this->_rows); + $row = current($this->rows); if (!$row) { return $row; } $return = array(); - foreach ($this->_rows[0] as $key => $val) { + foreach ($this->rows[0] as $key => $val) { $return[$key] = $row[$key]; } - next($this->_rows); + next($this->rows); return $return; } @@ -103,11 +104,11 @@ if (isset($_GET["mongo"])) { } function fetch_field() { - $keys = array_keys($this->_rows[0]); - $name = $keys[$this->_offset++]; + $keys = array_keys($this->rows[0]); + $name = $keys[$this->offset++]; return (object) array( 'name' => $name, - 'charsetnr' => $this->_charset[$name], + 'charsetnr' => $this->charset[$name], ); } } diff --git a/adminer/drivers/mssql.inc.php b/adminer/drivers/mssql.inc.php index a5136c2b..93d00541 100644 --- a/adminer/drivers/mssql.inc.php +++ b/adminer/drivers/mssql.inc.php @@ -13,7 +13,8 @@ if (isset($_GET["mssql"])) { define('Adminer\DRIVER', "mssql"); if (extension_loaded("sqlsrv")) { class Db { - var $extension = "sqlsrv", $_link, $_result, $server_info, $affected_rows, $errno, $error; + var $extension = "sqlsrv", $server_info, $affected_rows, $errno, $error; + private $link, $result; function _get_error() { $this->error = ""; @@ -38,14 +39,14 @@ if (isset($_GET["mssql"])) { if ($db != "") { $connection_info["Database"] = $db; } - $this->_link = @sqlsrv_connect(preg_replace('~:~', ',', $server), $connection_info); - if ($this->_link) { - $info = sqlsrv_server_info($this->_link); + $this->link = @sqlsrv_connect(preg_replace('~:~', ',', $server), $connection_info); + if ($this->link) { + $info = sqlsrv_server_info($this->link); $this->server_info = $info['SQLServerVersion']; } else { $this->_get_error(); } - return (bool) $this->_link; + return (bool) $this->link; } function quote($string) { @@ -58,7 +59,7 @@ if (isset($_GET["mssql"])) { } function query($query, $unbuffered = false) { - $result = sqlsrv_query($this->_link, $query); //! , array(), ($unbuffered ? array() : array("Scrollable" => "keyset")) + $result = sqlsrv_query($this->link, $query); //! , array(), ($unbuffered ? array() : array("Scrollable" => "keyset")) $this->error = ""; if (!$result) { $this->_get_error(); @@ -68,9 +69,9 @@ if (isset($_GET["mssql"])) { } function multi_query($query) { - $this->_result = sqlsrv_query($this->_link, $query); + $this->result = sqlsrv_query($this->link, $query); $this->error = ""; - if (!$this->_result) { + if (!$this->result) { $this->_get_error(); return false; } @@ -79,7 +80,7 @@ if (isset($_GET["mssql"])) { function store_result($result = null) { if (!$result) { - $result = $this->_result; + $result = $this->result; } if (!$result) { return false; @@ -92,7 +93,7 @@ if (isset($_GET["mssql"])) { } function next_result() { - return $this->_result ? sqlsrv_next_result($this->_result) : null; + return $this->result ? sqlsrv_next_result($this->result) : null; } function result($query, $field = 0) { @@ -106,10 +107,11 @@ if (isset($_GET["mssql"])) { } class Result { - var $_result, $_offset = 0, $_fields, $num_rows; + var $num_rows; + private $result, $offset = 0, $fields; function __construct($result) { - $this->_result = $result; + $this->result = $result; // $this->num_rows = sqlsrv_num_rows($result); // available only in scrollable results } @@ -124,18 +126,18 @@ if (isset($_GET["mssql"])) { } function fetch_assoc() { - return $this->_convert(sqlsrv_fetch_array($this->_result, SQLSRV_FETCH_ASSOC)); + return $this->_convert(sqlsrv_fetch_array($this->result, SQLSRV_FETCH_ASSOC)); } function fetch_row() { - return $this->_convert(sqlsrv_fetch_array($this->_result, SQLSRV_FETCH_NUMERIC)); + return $this->_convert(sqlsrv_fetch_array($this->result, SQLSRV_FETCH_NUMERIC)); } function fetch_field() { - if (!$this->_fields) { - $this->_fields = sqlsrv_field_metadata($this->_result); + if (!$this->fields) { + $this->fields = sqlsrv_field_metadata($this->result); } - $field = $this->_fields[$this->_offset++]; + $field = $this->fields[$this->offset++]; $return = new \stdClass; $return->name = $field["Name"]; $return->orgname = $field["Name"]; @@ -145,12 +147,12 @@ if (isset($_GET["mssql"])) { function seek($offset) { for ($i=0; $i < $offset; $i++) { - sqlsrv_fetch($this->_result); // SQLSRV_SCROLL_ABSOLUTE added in sqlsrv 1.1 + sqlsrv_fetch($this->result); // SQLSRV_SCROLL_ABSOLUTE added in sqlsrv 1.1 } } function __destruct() { - sqlsrv_free_stmt($this->_result); + sqlsrv_free_stmt($this->result); } } diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index 691ff28b..560848fb 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -65,9 +65,9 @@ if (!defined('Adminer\DRIVER')) { $server_info, ///< @var string server version $affected_rows, ///< @var int number of affected rows $errno, ///< @var int last error code - $error, ///< @var string last error message - $_link, $_result ///< @access private + $error ///< @var string last error message ; + private $link, $result; /** Connect to server * @param string @@ -80,19 +80,19 @@ if (!defined('Adminer\DRIVER')) { $this->error = lang('Disable %s or enable %s or %s extensions.', "'mysql.allow_local_infile'", "MySQLi", "PDO_MySQL"); return false; } - $this->_link = @mysql_connect( + $this->link = @mysql_connect( ($server != "" ? $server : ini_get("mysql.default_host")), ("$server$username" != "" ? $username : ini_get("mysql.default_user")), ("$server$username$password" != "" ? $password : ini_get("mysql.default_password")), true, 131072 // CLIENT_MULTI_RESULTS for CALL ); - if ($this->_link) { - $this->server_info = mysql_get_server_info($this->_link); + if ($this->link) { + $this->server_info = mysql_get_server_info($this->link); } else { $this->error = mysql_error(); } - return (bool) $this->_link; + return (bool) $this->link; } /** Sets the client character set @@ -101,11 +101,11 @@ if (!defined('Adminer\DRIVER')) { */ function set_charset($charset) { if (function_exists('mysql_set_charset')) { - if (mysql_set_charset($charset, $this->_link)) { + if (mysql_set_charset($charset, $this->link)) { return true; } // the client library may not support utf8mb4 - mysql_set_charset('utf8', $this->_link); + mysql_set_charset('utf8', $this->link); } return $this->query("SET NAMES $charset"); } @@ -115,7 +115,7 @@ if (!defined('Adminer\DRIVER')) { * @return string escaped string enclosed in ' */ function quote($string) { - return "'" . mysql_real_escape_string($string, $this->_link) . "'"; + return "'" . mysql_real_escape_string($string, $this->link) . "'"; } /** Select database @@ -123,7 +123,7 @@ if (!defined('Adminer\DRIVER')) { * @return bool */ function select_db($database) { - return mysql_select_db($database, $this->_link); + return mysql_select_db($database, $this->link); } /** Send query @@ -132,16 +132,16 @@ if (!defined('Adminer\DRIVER')) { * @return mixed bool or Result */ function query($query, $unbuffered = false) { - $result = @($unbuffered ? mysql_unbuffered_query($query, $this->_link) : mysql_query($query, $this->_link)); // @ - mute mysql.trace_mode + $result = @($unbuffered ? mysql_unbuffered_query($query, $this->link) : mysql_query($query, $this->link)); // @ - mute mysql.trace_mode $this->error = ""; if (!$result) { - $this->errno = mysql_errno($this->_link); - $this->error = mysql_error($this->_link); + $this->errno = mysql_errno($this->link); + $this->error = mysql_error($this->link); return false; } if ($result === true) { - $this->affected_rows = mysql_affected_rows($this->_link); - $this->info = mysql_info($this->_link); + $this->affected_rows = mysql_affected_rows($this->link); + $this->info = mysql_info($this->link); return true; } return new Result($result); @@ -152,14 +152,14 @@ if (!defined('Adminer\DRIVER')) { * @return bool */ function multi_query($query) { - return $this->_result = $this->query($query); + return $this->result = $this->query($query); } /** Get current resultset * @return Result */ function store_result() { - return $this->_result; + return $this->result; } /** Fetch next resultset @@ -180,21 +180,19 @@ if (!defined('Adminer\DRIVER')) { if (!$result || !$result->num_rows) { return false; } - return mysql_result($result->_result, 0, $field); + return mysql_result($result->result, 0, $field); } } class Result { - var - $num_rows, ///< @var int number of rows in the result - $_result, $_offset = 0 ///< @access private - ; + var $num_rows; ///< @var int number of rows in the result + private $result, $offset = 0; /** Constructor * @param resource */ function __construct($result) { - $this->_result = $result; + $this->result = $result; $this->num_rows = mysql_num_rows($result); } @@ -202,21 +200,21 @@ if (!defined('Adminer\DRIVER')) { * @return array */ function fetch_assoc() { - return mysql_fetch_assoc($this->_result); + return mysql_fetch_assoc($this->result); } /** Fetch next row as numbered array * @return array */ function fetch_row() { - return mysql_fetch_row($this->_result); + return mysql_fetch_row($this->result); } /** Fetch next field * @return object properties: name, type, orgtable, orgname, charsetnr */ function fetch_field() { - $return = mysql_fetch_field($this->_result, $this->_offset++); // offset required under certain conditions + $return = mysql_fetch_field($this->result, $this->offset++); // offset required under certain conditions $return->orgtable = $return->table; $return->orgname = $return->name; $return->charsetnr = ($return->blob ? 63 : 0); @@ -226,7 +224,7 @@ if (!defined('Adminer\DRIVER')) { /** Free result set */ function __destruct() { - mysql_free_result($this->_result); + mysql_free_result($this->result); } } diff --git a/adminer/drivers/oracle.inc.php b/adminer/drivers/oracle.inc.php index 5282a972..9d368844 100644 --- a/adminer/drivers/oracle.inc.php +++ b/adminer/drivers/oracle.inc.php @@ -7,7 +7,8 @@ if (isset($_GET["oracle"])) { define('Adminer\DRIVER', "oracle"); if (extension_loaded("oci8")) { class Db { - var $extension = "oci8", $_link, $_result, $server_info, $affected_rows, $errno, $error; + var $extension = "oci8", $server_info, $affected_rows, $errno, $error; + private $link, $result; var $_current_db; function _error($errno, $error) { @@ -19,9 +20,9 @@ if (isset($_GET["oracle"])) { } function connect($server, $username, $password) { - $this->_link = @oci_new_connect($username, $password, $server, "AL32UTF8"); - if ($this->_link) { - $this->server_info = oci_server_version($this->_link); + $this->link = @oci_new_connect($username, $password, $server, "AL32UTF8"); + if ($this->link) { + $this->server_info = oci_server_version($this->link); return true; } $error = oci_error(); @@ -39,10 +40,10 @@ if (isset($_GET["oracle"])) { } function query($query, $unbuffered = false) { - $result = oci_parse($this->_link, $query); + $result = oci_parse($this->link, $query); $this->error = ""; if (!$result) { - $error = oci_error($this->_link); + $error = oci_error($this->link); $this->errno = $error["code"]; $this->error = $error["message"]; return false; @@ -61,11 +62,11 @@ if (isset($_GET["oracle"])) { } function multi_query($query) { - return $this->_result = $this->query($query); + return $this->result = $this->query($query); } function store_result() { - return $this->_result; + return $this->result; } function next_result() { @@ -74,21 +75,22 @@ if (isset($_GET["oracle"])) { function result($query, $field = 0) { $result = $this->query($query); - if (!is_object($result) || !oci_fetch($result->_result)) { + if (!is_object($result) || !oci_fetch($result->result)) { return false; } - return oci_result($result->_result, $field + 1); + return oci_result($result->result, $field + 1); } } class Result { - var $_result, $_offset = 1, $num_rows; + var $num_rows; + private $result, $offset = 1; function __construct($result) { - $this->_result = $result; + $this->result = $result; } - function _convert($row) { + private function convert($row) { foreach ((array) $row as $key => $val) { if (is_a($val, 'OCI-Lob')) { $row[$key] = $val->load(); @@ -98,25 +100,25 @@ if (isset($_GET["oracle"])) { } function fetch_assoc() { - return $this->_convert(oci_fetch_assoc($this->_result)); + return $this->convert(oci_fetch_assoc($this->result)); } function fetch_row() { - return $this->_convert(oci_fetch_row($this->_result)); + return $this->convert(oci_fetch_row($this->result)); } function fetch_field() { - $column = $this->_offset++; + $column = $this->offset++; $return = new \stdClass; - $return->name = oci_field_name($this->_result, $column); + $return->name = oci_field_name($this->result, $column); $return->orgname = $return->name; - $return->type = oci_field_type($this->_result, $column); + $return->type = oci_field_type($this->result, $column); $return->charsetnr = (preg_match("~raw|blob|bfile~", $return->type) ? 63 : 0); // 63 - binary return $return; } function __destruct() { - oci_free_statement($this->_result); + oci_free_statement($this->result); } } diff --git a/adminer/drivers/pgsql.inc.php b/adminer/drivers/pgsql.inc.php index 62418c9b..a805a3c8 100644 --- a/adminer/drivers/pgsql.inc.php +++ b/adminer/drivers/pgsql.inc.php @@ -7,7 +7,8 @@ if (isset($_GET["pgsql"])) { define('Adminer\DRIVER', "pgsql"); if (extension_loaded("pgsql")) { class Db { - var $extension = "PgSQL", $_link, $_result, $_string, $_database = true, $server_info, $affected_rows, $error, $timeout; + var $extension = "PgSQL", $server_info, $affected_rows, $error, $timeout; + private $link, $result, $string, $database = true; function _error($errno, $error) { if (ini_bool("html_errors")) { @@ -21,28 +22,28 @@ if (isset($_GET["pgsql"])) { global $adminer; $db = $adminer->database(); set_error_handler(array($this, '_error')); - $this->_string = "host='" . str_replace(":", "' port='", addcslashes($server, "'\\")) . "' user='" . addcslashes($username, "'\\") . "' password='" . addcslashes($password, "'\\") . "'"; + $this->string = "host='" . str_replace(":", "' port='", addcslashes($server, "'\\")) . "' user='" . addcslashes($username, "'\\") . "' password='" . addcslashes($password, "'\\") . "'"; $ssl = $adminer->connectSsl(); if (isset($ssl["mode"])) { - $this->_string .= " sslmode='" . $ssl["mode"] . "'"; + $this->string .= " sslmode='" . $ssl["mode"] . "'"; } - $this->_link = @pg_connect("$this->_string dbname='" . ($db != "" ? addcslashes($db, "'\\") : "postgres") . "'", PGSQL_CONNECT_FORCE_NEW); - if (!$this->_link && $db != "") { + $this->link = @pg_connect("$this->string dbname='" . ($db != "" ? addcslashes($db, "'\\") : "postgres") . "'", PGSQL_CONNECT_FORCE_NEW); + if (!$this->link && $db != "") { // try to connect directly with database for performance - $this->_database = false; - $this->_link = @pg_connect("$this->_string dbname='postgres'", PGSQL_CONNECT_FORCE_NEW); + $this->database = false; + $this->link = @pg_connect("$this->string dbname='postgres'", PGSQL_CONNECT_FORCE_NEW); } restore_error_handler(); - if ($this->_link) { - $version = pg_version($this->_link); + if ($this->link) { + $version = pg_version($this->link); $this->server_info = $version["server"]; - pg_set_client_encoding($this->_link, "UTF8"); + pg_set_client_encoding($this->link, "UTF8"); } - return (bool) $this->_link; + return (bool) $this->link; } function quote($string) { - return pg_escape_literal($this->_link, $string); + return pg_escape_literal($this->link, $string); } function value($val, $field) { @@ -50,30 +51,30 @@ if (isset($_GET["pgsql"])) { } function quoteBinary($string) { - return "'" . pg_escape_bytea($this->_link, $string) . "'"; + return "'" . pg_escape_bytea($this->link, $string) . "'"; } function select_db($database) { global $adminer; if ($database == $adminer->database()) { - return $this->_database; + return $this->database; } - $return = @pg_connect("$this->_string dbname='" . addcslashes($database, "'\\") . "'", PGSQL_CONNECT_FORCE_NEW); + $return = @pg_connect("$this->string dbname='" . addcslashes($database, "'\\") . "'", PGSQL_CONNECT_FORCE_NEW); if ($return) { - $this->_link = $return; + $this->link = $return; } return $return; } function close() { - $this->_link = @pg_connect("$this->_string dbname='postgres'"); + $this->link = @pg_connect("$this->string dbname='postgres'"); } function query($query, $unbuffered = false) { - $result = @pg_query($this->_link, $query); + $result = @pg_query($this->link, $query); $this->error = ""; if (!$result) { - $this->error = pg_last_error($this->_link); + $this->error = pg_last_error($this->link); $return = false; } elseif (!pg_num_fields($result)) { $this->affected_rows = pg_affected_rows($result); @@ -89,11 +90,11 @@ if (isset($_GET["pgsql"])) { } function multi_query($query) { - return $this->_result = $this->query($query); + return $this->result = $this->query($query); } function store_result() { - return $this->_result; + return $this->result; } function next_result() { @@ -106,45 +107,46 @@ if (isset($_GET["pgsql"])) { if (!$result || !$result->num_rows) { return false; } - return pg_fetch_result($result->_result, 0, $field); + return pg_fetch_result($result->result, 0, $field); } function warnings() { - return h(pg_last_notice($this->_link)); // second parameter is available since PHP 7.1.0 + return h(pg_last_notice($this->link)); // second parameter is available since PHP 7.1.0 } } class Result { - var $_result, $_offset = 0, $num_rows; + var $num_rows; + private $result, $offset = 0; function __construct($result) { - $this->_result = $result; + $this->result = $result; $this->num_rows = pg_num_rows($result); } function fetch_assoc() { - return pg_fetch_assoc($this->_result); + return pg_fetch_assoc($this->result); } function fetch_row() { - return pg_fetch_row($this->_result); + return pg_fetch_row($this->result); } function fetch_field() { - $column = $this->_offset++; + $column = $this->offset++; $return = new \stdClass; if (function_exists('pg_field_table')) { - $return->orgtable = pg_field_table($this->_result, $column); + $return->orgtable = pg_field_table($this->result, $column); } - $return->name = pg_field_name($this->_result, $column); + $return->name = pg_field_name($this->result, $column); $return->orgname = $return->name; - $return->type = pg_field_type($this->_result, $column); + $return->type = pg_field_type($this->result, $column); $return->charsetnr = ($return->type == "bytea" ? 63 : 0); // 63 - binary return $return; } function __destruct() { - pg_free_result($this->_result); + pg_free_result($this->result); } } diff --git a/adminer/drivers/sqlite.inc.php b/adminer/drivers/sqlite.inc.php index 5c3394a3..eb0a8b97 100644 --- a/adminer/drivers/sqlite.inc.php +++ b/adminer/drivers/sqlite.inc.php @@ -8,37 +8,38 @@ if (isset($_GET["sqlite"])) { if (class_exists("SQLite3")) { class SqliteDb { - var $extension = "SQLite3", $server_info, $affected_rows, $errno, $error, $_link; + var $extension = "SQLite3", $server_info, $affected_rows, $errno, $error; + private $link; function __construct($filename) { - $this->_link = new \SQLite3($filename); - $version = $this->_link->version(); + $this->link = new \SQLite3($filename); + $version = $this->link->version(); $this->server_info = $version["versionString"]; } function query($query) { - $result = @$this->_link->query($query); + $result = @$this->link->query($query); $this->error = ""; if (!$result) { - $this->errno = $this->_link->lastErrorCode(); - $this->error = $this->_link->lastErrorMsg(); + $this->errno = $this->link->lastErrorCode(); + $this->error = $this->link->lastErrorMsg(); return false; } elseif ($result->numColumns()) { return new Result($result); } - $this->affected_rows = $this->_link->changes(); + $this->affected_rows = $this->link->changes(); return true; } function quote($string) { return (is_utf8($string) - ? "'" . $this->_link->escapeString($string) . "'" + ? "'" . $this->link->escapeString($string) . "'" : "x'" . reset(unpack('H*', $string)) . "'" ); } function store_result() { - return $this->_result; + return $this->result; } function result($query, $field = 0) { @@ -46,38 +47,39 @@ if (isset($_GET["sqlite"])) { if (!is_object($result)) { return false; } - $row = $result->_result->fetchArray(); + $row = $result->result->fetchArray(); return $row ? $row[$field] : false; } } class Result { - var $_result, $_offset = 0, $num_rows; + var $num_rows; + private $result, $offset = 0; function __construct($result) { - $this->_result = $result; + $this->result = $result; } function fetch_assoc() { - return $this->_result->fetchArray(SQLITE3_ASSOC); + return $this->result->fetchArray(SQLITE3_ASSOC); } function fetch_row() { - return $this->_result->fetchArray(SQLITE3_NUM); + return $this->result->fetchArray(SQLITE3_NUM); } function fetch_field() { - $column = $this->_offset++; - $type = $this->_result->columnType($column); + $column = $this->offset++; + $type = $this->result->columnType($column); return (object) array( - "name" => $this->_result->columnName($column), + "name" => $this->result->columnName($column), "type" => $type, "charsetnr" => ($type == SQLITE3_BLOB ? 63 : 0), // 63 - binary ); } function __desctruct() { - return $this->_result->finalize(); + return $this->result->finalize(); } } @@ -115,7 +117,7 @@ if (isset($_GET["sqlite"])) { } function multi_query($query) { - return $this->_result = $this->query($query); + return $this->result = $this->query($query); } function next_result() { diff --git a/adminer/include/pdo.inc.php b/adminer/include/pdo.inc.php index bde1535c..9dc1858e 100644 --- a/adminer/include/pdo.inc.php +++ b/adminer/include/pdo.inc.php @@ -4,7 +4,8 @@ namespace Adminer; // PDO can be used in several database drivers if (extension_loaded('pdo')) { abstract class PdoDb { - var $_result, $server_info, $affected_rows, $errno, $error, $pdo; + var $server_info, $affected_rows, $errno, $error, $pdo; + private $result; function dsn($dsn, $username, $password, $options = array()) { $options[\PDO::ATTR_ERRMODE] = \PDO::ERRMODE_SILENT; @@ -38,12 +39,12 @@ if (extension_loaded('pdo')) { } function multi_query($query) { - return $this->_result = $this->query($query); + return $this->result = $this->query($query); } function store_result($result = null) { if (!$result) { - $result = $this->_result; + $result = $this->result; if (!$result) { return false; } @@ -57,11 +58,11 @@ if (extension_loaded('pdo')) { } function next_result() { - if (!$this->_result) { + if (!$this->result) { return false; } - $this->_result->_offset = 0; - return @$this->_result->nextRowset(); // @ - PDO_PgSQL doesn't support it + $this->result->_offset = 0; + return @$this->result->nextRowset(); // @ - PDO_PgSQL doesn't support it } function result($query, $field = 0) { diff --git a/adminer/include/tmpfile.inc.php b/adminer/include/tmpfile.inc.php index 76fb3617..b75f478f 100644 --- a/adminer/include/tmpfile.inc.php +++ b/adminer/include/tmpfile.inc.php @@ -2,8 +2,7 @@ namespace Adminer; class TmpFile { - var $handler; - var $size; + private $handler, $size; function __construct() { $this->handler = tmpfile(); diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index 83353b87..cd1beb32 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -3,7 +3,7 @@ namespace Adminer; class Adminer { var $operators = array("<=", ">="); - var $_values = array(); + private $values = array(); function name() { return "" . lang('Editor') . ""; @@ -175,7 +175,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row //! requires MySQL 5 $ids[$row[$key]] = q($row[$key]); } // uses constant number of queries to get the descriptions, join would be complex, multiple queries would be slow - $descriptions = $this->_values[$table]; + $descriptions = $this->values[$table]; if (!$descriptions) { $descriptions = get_key_vals("SELECT $id, $name FROM " . table($table) . " WHERE $id IN (" . implode(", ", $ids) . ")"); } @@ -653,7 +653,7 @@ qsl('div').onclick = whisperClick;", "") function _foreignKeyOptions($table, $column, $value = null) { if (list($target, $id, $name) = $this->_foreignColumn(column_foreign_keys($table), $column)) { - $return = &$this->_values[$target]; + $return = &$this->values[$target]; if ($return === null) { $table_status = table_status($target); $return = ($table_status["Rows"] > 1000 ? "" : array("" => "") + get_key_vals("SELECT $id, $name FROM " . table($target) . " ORDER BY 2")); diff --git a/plugins/drivers/clickhouse.php b/plugins/drivers/clickhouse.php index d933e832..8b246034 100644 --- a/plugins/drivers/clickhouse.php +++ b/plugins/drivers/clickhouse.php @@ -8,11 +8,12 @@ if (isset($_GET["clickhouse"])) { if (ini_bool('allow_url_fopen')) { class Db { - var $extension = "JSON", $server_info, $errno, $_result, $error, $_url; + var $extension = "JSON", $server_info, $errno, $error; + private $result, $url; var $_db = 'default'; function rootQuery($db, $query) { - $file = @file_get_contents("$this->_url/?database=$db", false, stream_context_create(array('http' => array( + $file = @file_get_contents("$this->url/?database=$db", false, stream_context_create(array('http' => array( 'method' => 'POST', 'content' => $this->isQuerySelectLike($query) ? "$query FORMAT JSONCompact" : $query, 'header' => 'Content-type: application/x-www-form-urlencoded', @@ -57,7 +58,7 @@ if (isset($_GET["clickhouse"])) { function connect($server, $username, $password) { preg_match('~^(https?://)?(.*)~', $server, $match); - $this->_url = ($match[1] ?: "http://") . urlencode($username) . ":" . urlencode($password) . "@$match[2]"; + $this->url = ($match[1] ?: "http://") . urlencode($username) . ":" . urlencode($password) . "@$match[2]"; $return = $this->query('SELECT 1'); return (bool) $return; } @@ -72,11 +73,11 @@ if (isset($_GET["clickhouse"])) { } function multi_query($query) { - return $this->_result = $this->query($query); + return $this->result = $this->query($query); } function store_result() { - return $this->_result; + return $this->result; } function next_result() { @@ -90,7 +91,8 @@ if (isset($_GET["clickhouse"])) { } class Result { - var $num_rows, $_rows, $columns, $meta, $_offset = 0; + var $num_rows, $columns, $meta; + private $rows, $offset = 0; function __construct($result) { foreach ($result['data'] as $item) { @@ -98,28 +100,28 @@ if (isset($_GET["clickhouse"])) { foreach ($item as $key => $val) { $row[$key] = is_scalar($val) ? $val : json_encode($val, 256); // 256 - JSON_UNESCAPED_UNICODE } - $this->_rows[] = $row; + $this->rows[] = $row; } $this->num_rows = $result['rows']; $this->meta = $result['meta']; $this->columns = array_column($this->meta, 'name'); - reset($this->_rows); + reset($this->rows); } function fetch_assoc() { - $row = current($this->_rows); - next($this->_rows); + $row = current($this->rows); + next($this->rows); return $row === false ? false : array_combine($this->columns, $row); } function fetch_row() { - $row = current($this->_rows); - next($this->_rows); + $row = current($this->rows); + next($this->rows); return $row; } function fetch_field() { - $column = $this->_offset++; + $column = $this->offset++; $return = new \stdClass; if ($column < count($this->columns)) { $return->name = $this->meta[$column]['name']; diff --git a/plugins/drivers/elastic.php b/plugins/drivers/elastic.php index a11dd64f..9ee0257e 100644 --- a/plugins/drivers/elastic.php +++ b/plugins/drivers/elastic.php @@ -9,7 +9,8 @@ if (isset($_GET["elastic"])) { if (ini_bool('allow_url_fopen')) { class Db { - var $extension = "JSON", $server_info, $errno, $error, $_url; + var $extension = "JSON", $server_info, $errno, $error; + private $url; /** * @param string $path @@ -18,7 +19,7 @@ if (isset($_GET["elastic"])) { * @return array|false */ function rootQuery($path, array $content = null, $method = 'GET') { - $file = @file_get_contents("$this->_url/" . ltrim($path, '/'), false, stream_context_create(array('http' => array( + $file = @file_get_contents("$this->url/" . ltrim($path, '/'), false, stream_context_create(array('http' => array( 'method' => $method, 'content' => $content !== null ? json_encode($content) : null, 'header' => $content !== null ? 'Content-Type: application/json' : array(), @@ -78,7 +79,7 @@ if (isset($_GET["elastic"])) { */ function connect($server, $username, $password) { preg_match('~^(https?://)?(.*)~', $server, $match); - $this->_url = ($match[1] ?: "http://") . urlencode($username) . ":" . urlencode($password) . "@$match[2]"; + $this->url = ($match[1] ?: "http://") . urlencode($username) . ":" . urlencode($password) . "@$match[2]"; $return = $this->query(''); if ($return) { $this->server_info = $return['version']['number']; @@ -96,18 +97,19 @@ if (isset($_GET["elastic"])) { } class Result { - var $num_rows, $_rows; + var $num_rows; + private $rows; function __construct($rows) { $this->num_rows = count($rows); - $this->_rows = $rows; + $this->rows = $rows; - reset($this->_rows); + reset($this->rows); } function fetch_assoc() { - $return = current($this->_rows); - next($this->_rows); + $return = current($this->rows); + next($this->rows); return $return; } diff --git a/plugins/drivers/firebird.php b/plugins/drivers/firebird.php index 5049dd5f..c42a30f4 100644 --- a/plugins/drivers/firebird.php +++ b/plugins/drivers/firebird.php @@ -18,8 +18,9 @@ if (isset($_GET["firebird"])) { $affected_rows, $errno, $error, - $_link, $_result + $_link ; + private $result; function connect($server, $username, $password) { $this->_link = ibase_connect($server, $username, $password); @@ -58,11 +59,11 @@ if (isset($_GET["firebird"])) { } function multi_query($query) { - return $this->_result = $this->query($query); + return $this->result = $this->query($query); } function store_result() { - return $this->_result; + return $this->result; } function next_result() { @@ -80,23 +81,24 @@ if (isset($_GET["firebird"])) { } class Result { - var $num_rows, $_result, $_offset = 0; + var $num_rows; + private $result, $offset = 0; function __construct($result) { - $this->_result = $result; + $this->result = $result; // $this->num_rows = ibase_num_rows($result); } function fetch_assoc() { - return ibase_fetch_assoc($this->_result); + return ibase_fetch_assoc($this->result); } function fetch_row() { - return ibase_fetch_row($this->_result); + return ibase_fetch_row($this->result); } function fetch_field() { - $field = ibase_field_info($this->_result, $this->_offset++); + $field = ibase_field_info($this->result, $this->offset++); return (object) array( 'name' => $field['name'], 'orgname' => $field['name'], @@ -106,7 +108,7 @@ if (isset($_GET["firebird"])) { } function __destruct() { - ibase_free_result($this->_result); + ibase_free_result($this->result); } } diff --git a/plugins/drivers/simpledb.php b/plugins/drivers/simpledb.php index 36cfb820..56a8eb81 100644 --- a/plugins/drivers/simpledb.php +++ b/plugins/drivers/simpledb.php @@ -8,7 +8,8 @@ if (isset($_GET["simpledb"])) { if (class_exists('SimpleXMLElement') && ini_bool('allow_url_fopen')) { class Db { - var $extension = "SimpleXML", $server_info = '2009-04-15', $error, $timeout, $next, $affected_rows, $_result; + var $extension = "SimpleXML", $server_info = '2009-04-15', $error, $timeout, $next, $affected_rows; + private $result; function select_db($database) { return ($database == "domain"); @@ -38,11 +39,11 @@ if (isset($_GET["simpledb"])) { } function multi_query($query) { - return $this->_result = $this->query($query); + return $this->result = $this->query($query); } function store_result() { - return $this->_result; + return $this->result; } function next_result() { @@ -55,7 +56,8 @@ if (isset($_GET["simpledb"])) { } class Result { - var $num_rows, $_rows = array(), $_offset = 0; + var $num_rows; + private $rows = array(), $offset = 0; function __construct($result) { foreach ($result as $item) { @@ -73,14 +75,14 @@ if (isset($_GET["simpledb"])) { $row[$name] = $value; } } - $this->_rows[] = $row; + $this->rows[] = $row; foreach ($row as $key => $val) { - if (!isset($this->_rows[0][$key])) { - $this->_rows[0][$key] = null; + if (!isset($this->rows[0][$key])) { + $this->rows[0][$key] = null; } } } - $this->num_rows = count($this->_rows); + $this->num_rows = count($this->rows); } function _processValue($element) { @@ -88,15 +90,15 @@ if (isset($_GET["simpledb"])) { } function fetch_assoc() { - $row = current($this->_rows); + $row = current($this->rows); if (!$row) { return $row; } $return = array(); - foreach ($this->_rows[0] as $key => $val) { + foreach ($this->rows[0] as $key => $val) { $return[$key] = $row[$key]; } - next($this->_rows); + next($this->rows); return $return; } @@ -109,8 +111,8 @@ if (isset($_GET["simpledb"])) { } function fetch_field() { - $keys = array_keys($this->_rows[0]); - return (object) array('name' => $keys[$this->_offset++]); + $keys = array_keys($this->rows[0]); + return (object) array('name' => $keys[$this->offset++]); } } }