Use USE in PDO
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@234 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
parent
db3d23ce0e
commit
2e596b0243
|
@ -108,17 +108,14 @@ if (extension_loaded("mysqli")) {
|
||||||
|
|
||||||
} elseif (extension_loaded("pdo_mysql")) {
|
} elseif (extension_loaded("pdo_mysql")) {
|
||||||
class Min_PDO_MySQL extends PDO {
|
class Min_PDO_MySQL extends PDO {
|
||||||
var $_dsn, $_username, $_password, $_result, $server_info, $affected_rows, $error;
|
var $_result, $server_info, $affected_rows, $error;
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function connect($server, $username, $password) {
|
function connect($server, $username, $password) {
|
||||||
$this->_dsn = "mysql:host=$server";
|
|
||||||
$this->_username = $username;
|
|
||||||
$this->_password = $password;
|
|
||||||
set_exception_handler('auth_error'); // try/catch is not compatible with PHP 4
|
set_exception_handler('auth_error'); // try/catch is not compatible with PHP 4
|
||||||
parent::__construct($this->_dsn, $username, $password);
|
parent::__construct("mysql:host=$server", $username, $password);
|
||||||
restore_exception_handler();
|
restore_exception_handler();
|
||||||
$this->setAttribute(13, array('Min_PDOStatement')); // PDO::ATTR_STATEMENT_CLASS
|
$this->setAttribute(13, array('Min_PDOStatement')); // PDO::ATTR_STATEMENT_CLASS
|
||||||
$this->server_info = $this->result($this->query("SELECT VERSION()"));
|
$this->server_info = $this->result($this->query("SELECT VERSION()"));
|
||||||
|
@ -126,8 +123,7 @@ if (extension_loaded("mysqli")) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function select_db($database) {
|
function select_db($database) {
|
||||||
parent::__construct("$this->_dsn;dbname=$database", $this->_username, $this->_password); // semicolon in $database is not allowed by PDO
|
return $this->query("USE " . idf_escape($database));
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function query($query) {
|
function query($query) {
|
||||||
|
|
Loading…
Reference in a new issue