Introduced options parameter for query functions.

This commit is contained in:
Alexander M. Turek
2004-02-14 00:36:14 +00:00
parent fd25405391
commit 3102a23c09
5 changed files with 37 additions and 19 deletions

View File

@@ -5,6 +5,11 @@ phpMyAdmin - Changelog
$Id$
$Source$
2004-02-14 Alexander M. Turek <thewall@derrabus.de>
* libraries/database_interface.lib.php, libraries/dbi/*.dbi.lib.php:
Introduced options parameter for query functions.
* libraries/mysql_charsets.lib.php: Fixed a "MySQL out of sync" error.
2004-02-13 Alexander M. Turek <resist@derrabus.de>
* libraries/common.lib.php: Fixed bug #890186 (PMA chokes on undefined
parser functions if one of the very first queries fails.

View File

@@ -2,15 +2,22 @@
/* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4:
/**
* Common Option Constants For DBI Functions
*/
define('PMA_DBI_QUERY_STORE', 1); // Force STORE_RESULT method, ignored by classic MySQL.
/**
* Including The DBI Plugin
*/
require_once('./libraries/dbi/' . $cfg['Server']['extension'] . '.dbi.lib.php');
function PMA_DBI_query($query, $dbh = '') {
if (empty($dbh)) {
$dbh = $GLOBALS['userlink'];
}
$res = PMA_DBI_try_query($query, $dbh)
or PMA_mysqlDie(PMA_DBI_getError($dbh), $query);
/**
* Common Functions
*/
function PMA_DBI_query($query, $link = NULL, $options = 0) {
$res = PMA_DBI_try_query($query, $link, $options)
or PMA_mysqlDie(PMA_DBI_getError(), $query);
return $res;
}

View File

@@ -89,7 +89,7 @@ function PMA_DBI_connect($user, $password) {
return $link;
}
function PMA_DBI_select_db($dbname, $link = '') {
function PMA_DBI_select_db($dbname, $link = NULL) {
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
@@ -103,7 +103,7 @@ function PMA_DBI_select_db($dbname, $link = '') {
return mysql_select_db($dbname, $link);
}
function PMA_DBI_try_query($query, $link = '') {
function PMA_DBI_try_query($query, $link = NULL, $options = 0) {
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
@@ -169,7 +169,7 @@ function PMA_DBI_free_result($result) {
return @mysql_free_result($result);
}
function PMA_DBI_getError($link = '') {
function PMA_DBI_getError($link = NULL) {
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
@@ -186,7 +186,7 @@ function PMA_DBI_getError($link = '') {
return $error;
}
function PMA_DBI_close($link = '') {
function PMA_DBI_close($link = NULL) {
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
@@ -201,7 +201,7 @@ function PMA_DBI_num_rows($result) {
return mysql_num_rows($result);
}
function PMA_DBI_insert_id($link = '') {
function PMA_DBI_insert_id($link = NULL) {
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];

View File

@@ -76,7 +76,7 @@ function PMA_DBI_connect($user, $password) {
return $link;
}
function PMA_DBI_select_db($dbname, $link = '') {
function PMA_DBI_select_db($dbname, $link = NULL) {
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
@@ -90,7 +90,13 @@ function PMA_DBI_select_db($dbname, $link = '') {
return mysqli_select_db($link, $dbname);
}
function PMA_DBI_try_query($query, $link = '') {
function PMA_DBI_try_query($query, $link = NULL, $options = 0) {
if ($options == $options | PMA_DBI_QUERY_STORE) {
$method = MYSQLI_STORE_RESULT;
} else {
$method = MYSQLI_USE_RESULT;
}
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
@@ -101,7 +107,7 @@ function PMA_DBI_try_query($query, $link = '') {
if (PMA_MYSQL_INT_VERSION < 40100) {
$query = PMA_convert_charset($query);
}
return mysqli_query($link, $query, MYSQLI_USE_RESULT);
return mysqli_query($link, $query, $method);
}
// The following function is meant for internal use only.
@@ -155,7 +161,7 @@ function PMA_DBI_free_result($result) {
return @mysqli_free_result($result);
}
function PMA_DBI_getError($link = '') {
function PMA_DBI_getError($link = NULL) {
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
@@ -172,7 +178,7 @@ function PMA_DBI_getError($link = '') {
return $error;
}
function PMA_DBI_close($link = '') {
function PMA_DBI_close($link = NULL) {
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
@@ -217,4 +223,4 @@ function PMA_DBI_num_fields($result) {
return mysqli_num_fields($result);
}
?>
?>

View File

@@ -231,7 +231,7 @@ if (PMA_MYSQL_INT_VERSION >= 40100){
// MySQL 4.1.0 does not support seperate charset settings
// for databases.
$res = PMA_DBI_query('SHOW CREATE DATABASE ' . PMA_backquote($db) . ';');
$res = PMA_DBI_query('SHOW CREATE DATABASE ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE);
$row = PMA_DBI_fetch_row($res);
PMA_DBI_free_result($res);
PMA_DBI_free_result($res);