Replace direct mysql_xxx() calls with query_xxx() calls. Replace calls to mysql_insert_id()
with calls specific to the appdb or bugzilla database. Fixes a bug where a call to mysql_insert_id() can potentially retrieve an id from either the bugzilla or appdb database, depending on whichever database was last opened by mysql_connect().
This commit is contained in:
@@ -4,14 +4,14 @@ $hBugzillaLink = null;
|
||||
|
||||
define("MYSQL_DEADLOCK_ERRNO", 1213);
|
||||
|
||||
function query_appdb($sQuery,$sComment="")
|
||||
function query_appdb($sQuery, $sComment="")
|
||||
{
|
||||
global $hAppdbLink;
|
||||
|
||||
if(!is_resource($hAppdbLink))
|
||||
{
|
||||
// The last argument makes sure we are really opening a new connection
|
||||
$hAppdbLink = mysql_connect(APPS_DBHOST, APPS_DBUSER, APPS_DBPASS,true);
|
||||
$hAppdbLink = mysql_connect(APPS_DBHOST, APPS_DBUSER, APPS_DBPASS, true);
|
||||
mysql_select_db(APPS_DB, $hAppdbLink);
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ function query_parameters()
|
||||
if(!is_resource($hAppdbLink))
|
||||
{
|
||||
// The last argument makes sure we are really opening a new connection
|
||||
$hAppdbLink = mysql_connect(APPS_DBHOST, APPS_DBUSER, APPS_DBPASS,true);
|
||||
$hAppdbLink = mysql_connect(APPS_DBHOST, APPS_DBUSER, APPS_DBPASS, true);
|
||||
mysql_select_db(APPS_DB, $hAppdbLink);
|
||||
}
|
||||
|
||||
@@ -159,4 +159,61 @@ function query_error($sQuery, $sComment="")
|
||||
$bInQueryError = false; // clear variable upon exit
|
||||
}
|
||||
|
||||
function query_fetch_row($hResult)
|
||||
{
|
||||
return mysql_fetch_row($hResult);
|
||||
}
|
||||
|
||||
function query_fetch_object($hResult)
|
||||
{
|
||||
return mysql_fetch_object($hResult);
|
||||
}
|
||||
|
||||
function query_appdb_insert_id()
|
||||
{
|
||||
global $hAppdbLink;
|
||||
return mysql_insert_id($hAppdbLink);
|
||||
}
|
||||
|
||||
function query_bugzilla_insert_id()
|
||||
{
|
||||
global $hBugzillaLink;
|
||||
return mysql_insert_id($hBugzillaLink);
|
||||
}
|
||||
|
||||
function query_num_rows($hResult)
|
||||
{
|
||||
return mysql_num_rows($hResult);
|
||||
}
|
||||
|
||||
function query_escape_string($sString)
|
||||
{
|
||||
return mysql_real_escape_string($sString);
|
||||
}
|
||||
|
||||
function query_field_type($hResult, $iFieldOffset)
|
||||
{
|
||||
return mysql_field_type($hResult, $iFieldOffset);
|
||||
}
|
||||
|
||||
function query_field_name($hResult, $iFieldOffset)
|
||||
{
|
||||
return mysql_field_name($hResult, $iFieldOffset);
|
||||
}
|
||||
|
||||
function query_field_len($hResult, $ifieldOffset)
|
||||
{
|
||||
return mysql_field_len($hResult, $iFieldOffset);
|
||||
}
|
||||
|
||||
function query_field_flags($hResult, $iFieldOffset)
|
||||
{
|
||||
return mysql_field_flags($hResult, $iFieldOffset);
|
||||
}
|
||||
|
||||
function query_fetch_field($hResult, $iFieldOffset)
|
||||
{
|
||||
return mysql_fetch_field($hResult, $iFieldOffset);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user