Files
adminer/adminer/include/db.inc.php

57 lines
1.6 KiB
PHP
Raw Normal View History

2025-03-27 15:28:14 +01:00
<?php
namespace Adminer;
// this could be interface when "Db extends \mysqli" can have compatible type declarations (PHP 7)
// interfaces can include properties only since PHP 8.4
abstract class SqlDb {
/** @var Db */ static $instance;
/** @var string */ public $extension; // extension name
/** @var string */ public $flavor = ''; // different vendor with the same API, e.g. MariaDB; usually stays empty
/** @var string */ public $server_info; // server version
/** @var int */ public $affected_rows = 0; // number of affected rows
/** @var string */ public $info = ''; // see https://php.net/mysql_info
/** @var int */ public $errno = 0; // last error code
/** @var string */ public $error = ''; // last error message
2025-03-27 15:28:14 +01:00
/** @var Result|bool */ protected $multi; // used for multiquery
2025-03-28 22:00:53 +01:00
/** Connect to server
* @return string error message
*/
abstract function attach(?string $server, string $username, string $password): string;
2025-03-27 15:28:14 +01:00
/** Quote string to use in SQL
* @return string escaped string enclosed in '
*/
abstract function quote(string $string): string;
2025-03-27 15:28:14 +01:00
2025-03-31 11:08:37 +02:00
/** Select database
* @return bool boolish
*/
abstract function select_db(string $database);
2025-03-27 15:28:14 +01:00
/** Send query
* @return Result|bool
*/
abstract function query(string $query, bool $unbuffered = false);
2025-03-27 15:28:14 +01:00
/** Send query with more resultsets
* @return Result|bool
*/
function multi_query(string $query) {
2025-03-27 15:28:14 +01:00
return $this->multi = $this->query($query);
}
/** Get current resultset
* @return Result|bool
*/
function store_result() {
return $this->multi;
}
2025-03-28 09:13:36 +01:00
/** Fetch next resultset */
function next_result(): bool {
2025-03-27 15:28:14 +01:00
return false;
}
}