removed closing of db connection, closing database connection is only required if script runs longer than database connection is needed
This commit is contained in:
@@ -287,15 +287,3 @@ if (is_array($foreignData['disp_row'])) {
|
|||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* Close MySql connections
|
|
||||||
*/
|
|
||||||
if (isset($controllink) && $controllink) {
|
|
||||||
@PMA_DBI_close($controllink);
|
|
||||||
}
|
|
||||||
if (isset($userlink) && $userlink) {
|
|
||||||
@PMA_DBI_close($userlink);
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
97
db_qbe.php
97
db_qbe.php
@@ -628,7 +628,7 @@ echo PMA_generate_common_hidden_inputs($url_params);
|
|||||||
<?php
|
<?php
|
||||||
$strTableListOptions = '';
|
$strTableListOptions = '';
|
||||||
$numTableListOptions = 0;
|
$numTableListOptions = 0;
|
||||||
foreach ($tbl_names AS $key => $val) {
|
foreach ($tbl_names as $key => $val) {
|
||||||
$strTableListOptions .= ' ';
|
$strTableListOptions .= ' ';
|
||||||
$strTableListOptions .= '<option value="' . htmlspecialchars($key) . '"' . $val . '>'
|
$strTableListOptions .= '<option value="' . htmlspecialchars($key) . '"' . $val . '>'
|
||||||
. str_replace(' ', ' ', htmlspecialchars($key)) . '</option>' . "\n";
|
. str_replace(' ', ' ', htmlspecialchars($key)) . '</option>' . "\n";
|
||||||
@@ -694,7 +694,7 @@ if (isset($Field) && count($Field) > 0) {
|
|||||||
$fromclause = '';
|
$fromclause = '';
|
||||||
|
|
||||||
// We only start this if we have fields, otherwise it would be dumb
|
// We only start this if we have fields, otherwise it would be dumb
|
||||||
foreach ($Field AS $value) {
|
foreach ($Field as $value) {
|
||||||
$parts = explode('.', $value);
|
$parts = explode('.', $value);
|
||||||
if (!empty($parts[0]) && !empty($parts[1])) {
|
if (!empty($parts[0]) && !empty($parts[1])) {
|
||||||
$tab_raw = urldecode($parts[0]);
|
$tab_raw = urldecode($parts[0]);
|
||||||
@@ -746,7 +746,7 @@ if (isset($Field) && count($Field) > 0) {
|
|||||||
// the last db selected is not always the one where we need to work)
|
// the last db selected is not always the one where we need to work)
|
||||||
PMA_DBI_select_db($db);
|
PMA_DBI_select_db($db);
|
||||||
|
|
||||||
foreach ($tab_all AS $tab) {
|
foreach ($tab_all as $tab) {
|
||||||
$ind_rs = PMA_DBI_query('SHOW INDEX FROM ' . PMA_backquote($tab) . ';');
|
$ind_rs = PMA_DBI_query('SHOW INDEX FROM ' . PMA_backquote($tab) . ';');
|
||||||
while ($ind = PMA_DBI_fetch_assoc($ind_rs)) {
|
while ($ind = PMA_DBI_fetch_assoc($ind_rs)) {
|
||||||
$col1 = $tab . '.' . $ind['Column_name'];
|
$col1 = $tab . '.' . $ind['Column_name'];
|
||||||
@@ -787,7 +787,7 @@ if (isset($Field) && count($Field) > 0) {
|
|||||||
// (that would mean that they were also found in the whereclauses
|
// (that would mean that they were also found in the whereclauses
|
||||||
// which would be great). if yes, we take only those
|
// which would be great). if yes, we take only those
|
||||||
if ($needsort == 1) {
|
if ($needsort == 1) {
|
||||||
foreach ($col_cand AS $col => $is_where) {
|
foreach ($col_cand as $col => $is_where) {
|
||||||
$tab = explode('.', $col);
|
$tab = explode('.', $col);
|
||||||
$tab = $tab[0];
|
$tab = $tab[0];
|
||||||
if ($is_where == 'Y') {
|
if ($is_where == 'Y') {
|
||||||
@@ -813,7 +813,7 @@ if (isset($Field) && count($Field) > 0) {
|
|||||||
if (count($col_cand) > 1) {
|
if (count($col_cand) > 1) {
|
||||||
// Of course we only want to check each table once
|
// Of course we only want to check each table once
|
||||||
$checked_tables = $col_cand;
|
$checked_tables = $col_cand;
|
||||||
foreach ($col_cand AS $tab) {
|
foreach ($col_cand as $tab) {
|
||||||
if ($checked_tables[$tab] != 1) {
|
if ($checked_tables[$tab] != 1) {
|
||||||
$tsize[$tab] = PMA_Table::countRecords($db, $tab, true, false);
|
$tsize[$tab] = PMA_Table::countRecords($db, $tab, true, false);
|
||||||
$checked_tables[$tab] = 1;
|
$checked_tables[$tab] = 1;
|
||||||
@@ -829,86 +829,7 @@ if (isset($Field) && count($Field) > 0) {
|
|||||||
}
|
}
|
||||||
} // end if (exactly one where clause)
|
} // end if (exactly one where clause)
|
||||||
|
|
||||||
/**
|
unset($tab_all[$master]);
|
||||||
* Removes unwanted entries from an array (PHP3 compliant)
|
|
||||||
*
|
|
||||||
* @param array the array to work with
|
|
||||||
* @param array the list of keys to remove
|
|
||||||
*
|
|
||||||
* @return array the cleaned up array
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
*/
|
|
||||||
function PMA_arrayShort($array, $key)
|
|
||||||
{
|
|
||||||
foreach ($array AS $k => $v) {
|
|
||||||
if ($k != $key) {
|
|
||||||
$reta[$k] = $v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!isset($reta)) {
|
|
||||||
$reta = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $reta;
|
|
||||||
} // end of the "PMA_arrayShort()" function
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds all related tables
|
|
||||||
*
|
|
||||||
* @param string wether to go from master to foreign or vice versa
|
|
||||||
*
|
|
||||||
* @return boolean always TRUE
|
|
||||||
*
|
|
||||||
* @global array the list of tables that we still couldn't connect
|
|
||||||
* @global array the list of allready connected tables
|
|
||||||
* @global string the current databse name
|
|
||||||
* @global string the super user connection id
|
|
||||||
* @global array the list of relation settings
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
*/
|
|
||||||
function PMA_getRelatives($from) {
|
|
||||||
global $tab_left, $tab_know, $fromclause;
|
|
||||||
global $controllink, $db, $cfgRelation;
|
|
||||||
|
|
||||||
if ($from == 'master') {
|
|
||||||
$to = 'foreign';
|
|
||||||
} else {
|
|
||||||
$to = 'master';
|
|
||||||
}
|
|
||||||
$in_know = '(\'' . implode('\', \'', $tab_know) . '\')';
|
|
||||||
$in_left = '(\'' . implode('\', \'', $tab_left) . '\')';
|
|
||||||
|
|
||||||
$rel_query = 'SELECT *'
|
|
||||||
. ' FROM ' . PMA_backquote($cfgRelation['relation'])
|
|
||||||
. ' WHERE ' . $from . '_db = \'' . PMA_sqlAddslashes($db) . '\''
|
|
||||||
. ' AND ' . $to . '_db = \'' . PMA_sqlAddslashes($db) . '\''
|
|
||||||
. ' AND ' . $from . '_table IN ' . $in_know
|
|
||||||
. ' AND ' . $to . '_table IN ' . $in_left;
|
|
||||||
PMA_DBI_select_db($cfgRelation['db'], $controllink);
|
|
||||||
$relations = @PMA_DBI_query($rel_query, $controllink);
|
|
||||||
PMA_DBI_select_db($db, $controllink);
|
|
||||||
while ($row = PMA_DBI_fetch_assoc($relations)) {
|
|
||||||
$found_table = $row[$to . '_table'];
|
|
||||||
if (isset($tab_left[$found_table])) {
|
|
||||||
$fromclause .= "\n" . ' LEFT JOIN '
|
|
||||||
. PMA_backquote($row[$to . '_table']) . ' ON '
|
|
||||||
. PMA_backquote($row[$from . '_table']) . '.'
|
|
||||||
. PMA_backquote($row[$from . '_field']) . ' = '
|
|
||||||
. PMA_backquote($row[$to . '_table']) . '.'
|
|
||||||
. PMA_backquote($row[$to . '_field']) . ' ';
|
|
||||||
$tab_know[$found_table] = $found_table;
|
|
||||||
$tab_left = PMA_arrayShort($tab_left, $found_table);
|
|
||||||
}
|
|
||||||
} // end while
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
} // end of the "PMA_getRelatives()" function
|
|
||||||
|
|
||||||
|
|
||||||
$tab_left = PMA_arrayShort($tab_all, $master);
|
|
||||||
$tab_know[$master] = $master;
|
$tab_know[$master] = $master;
|
||||||
|
|
||||||
$run = 0;
|
$run = 0;
|
||||||
@@ -922,9 +843,9 @@ if (isset($Field) && count($Field) > 0) {
|
|||||||
$run++;
|
$run++;
|
||||||
if ($run > 5) {
|
if ($run > 5) {
|
||||||
|
|
||||||
foreach ($tab_left AS $tab) {
|
foreach ($tab_left as $tab) {
|
||||||
$emerg .= ', ' . PMA_backquote($tab);
|
$emerg .= ', ' . PMA_backquote($tab);
|
||||||
$tab_left = PMA_arrayShort($tab_left, $tab);
|
unset($tab_left[$tab]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // end while
|
} // end while
|
||||||
|
@@ -284,18 +284,6 @@ function PMA_DBI_getError($link = null)
|
|||||||
return $error;
|
return $error;
|
||||||
}
|
}
|
||||||
|
|
||||||
function PMA_DBI_close($link = null)
|
|
||||||
{
|
|
||||||
if (empty($link)) {
|
|
||||||
if (isset($GLOBALS['userlink'])) {
|
|
||||||
$link = $GLOBALS['userlink'];
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return @mysql_close($link);
|
|
||||||
}
|
|
||||||
|
|
||||||
function PMA_DBI_num_rows($result)
|
function PMA_DBI_num_rows($result)
|
||||||
{
|
{
|
||||||
if (!is_bool($result)) {
|
if (!is_bool($result)) {
|
||||||
|
@@ -369,26 +369,6 @@ function PMA_DBI_getError($link = null)
|
|||||||
return $error;
|
return $error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* closes given database $link or $GLOBALS['userlink']
|
|
||||||
*
|
|
||||||
* @uses $GLOBALS['userlink']
|
|
||||||
* @uses mysqli_close()
|
|
||||||
* @param object mysqli $link the mysqli object
|
|
||||||
* @return boolean treu or false
|
|
||||||
*/
|
|
||||||
function PMA_DBI_close($link = null)
|
|
||||||
{
|
|
||||||
if (empty($link)) {
|
|
||||||
if (isset($GLOBALS['userlink'])) {
|
|
||||||
$link = $GLOBALS['userlink'];
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return @mysqli_close($link);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param object mysqli result $result
|
* @param object mysqli result $result
|
||||||
|
@@ -39,7 +39,6 @@
|
|||||||
* @uses PMA_escapeJsString()
|
* @uses PMA_escapeJsString()
|
||||||
* @uses PMA_getenv()
|
* @uses PMA_getenv()
|
||||||
* @uses PMA_generate_common_url()
|
* @uses PMA_generate_common_url()
|
||||||
* @uses PMA_DBI_close()
|
|
||||||
* @uses basename()
|
* @uses basename()
|
||||||
* @uses file_exists()
|
* @uses file_exists()
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
@@ -165,16 +164,6 @@ if (PMA_getenv('SCRIPT_NAME') && empty($_POST) && !$GLOBALS['checked_special'])
|
|||||||
echo '</div>' . "\n";
|
echo '</div>' . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Close database connections
|
|
||||||
*/
|
|
||||||
if (! empty($GLOBALS['controllink'])) {
|
|
||||||
@PMA_DBI_close($GLOBALS['controllink']);
|
|
||||||
}
|
|
||||||
if (! empty($GLOBALS['userlink'])) {
|
|
||||||
@PMA_DBI_close($GLOBALS['userlink']);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Include possible custom footers
|
// Include possible custom footers
|
||||||
if (file_exists('./config.footer.inc.php')) {
|
if (file_exists('./config.footer.inc.php')) {
|
||||||
require './config.footer.inc.php';
|
require './config.footer.inc.php';
|
||||||
|
@@ -107,7 +107,7 @@ function PMA_printRelationsParamDiagnostic($cfgRelation)
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo '<table>' . "\n";
|
echo '<table>' . "\n";
|
||||||
|
|
||||||
PMA_printDiagMessageForParameter('pmadb', $GLOBALS['cfg']['Server']['pmadb'], $messages, 'pmadb');
|
PMA_printDiagMessageForParameter('pmadb', $GLOBALS['cfg']['Server']['pmadb'], $messages, 'pmadb');
|
||||||
|
|
||||||
PMA_printDiagMessageForParameter('relation', isset($cfgRelation['relation']), $messages, 'relation');
|
PMA_printDiagMessageForParameter('relation', isset($cfgRelation['relation']), $messages, 'relation');
|
||||||
@@ -993,4 +993,56 @@ function PMA_getForeignData($foreigners, $field, $override_total, $foreign_filte
|
|||||||
return $foreignData;
|
return $foreignData;
|
||||||
} // end of 'PMA_getForeignData()' function
|
} // end of 'PMA_getForeignData()' function
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds all related tables
|
||||||
|
*
|
||||||
|
* @param string wether to go from master to foreign or vice versa
|
||||||
|
*
|
||||||
|
* @return boolean always TRUE
|
||||||
|
*
|
||||||
|
* @global array the list of tables that we still couldn't connect
|
||||||
|
* @global array the list of allready connected tables
|
||||||
|
* @global string the current databse name
|
||||||
|
* @global string the super user connection id
|
||||||
|
* @global array the list of relation settings
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function PMA_getRelatives($from) {
|
||||||
|
global $tab_left, $tab_know, $fromclause;
|
||||||
|
global $db, $cfgRelation;
|
||||||
|
|
||||||
|
if ($from == 'master') {
|
||||||
|
$to = 'foreign';
|
||||||
|
} else {
|
||||||
|
$to = 'master';
|
||||||
|
}
|
||||||
|
$in_know = '(\'' . implode('\', \'', $tab_know) . '\')';
|
||||||
|
$in_left = '(\'' . implode('\', \'', $tab_left) . '\')';
|
||||||
|
|
||||||
|
$rel_query = 'SELECT *'
|
||||||
|
. ' FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['relation'])
|
||||||
|
. ' WHERE ' . $from . '_db = \'' . PMA_sqlAddslashes($db) . '\''
|
||||||
|
. ' AND ' . $to . '_db = \'' . PMA_sqlAddslashes($db) . '\''
|
||||||
|
. ' AND ' . $from . '_table IN ' . $in_know
|
||||||
|
. ' AND ' . $to . '_table IN ' . $in_left;
|
||||||
|
$relations = @PMA_DBI_query($rel_query, $GLOBALS['controllink']);
|
||||||
|
while ($row = PMA_DBI_fetch_assoc($relations)) {
|
||||||
|
$found_table = $row[$to . '_table'];
|
||||||
|
if (isset($tab_left[$found_table])) {
|
||||||
|
$fromclause
|
||||||
|
.= "\n" . ' LEFT JOIN '
|
||||||
|
. PMA_backquote($db) . '.' . PMA_backquote($row[$to . '_table']) . ' ON '
|
||||||
|
. PMA_backquote($row[$from . '_table']) . '.'
|
||||||
|
. PMA_backquote($row[$from . '_field']) . ' = '
|
||||||
|
. PMA_backquote($row[$to . '_table']) . '.'
|
||||||
|
. PMA_backquote($row[$to . '_field']) . ' ';
|
||||||
|
$tab_know[$found_table] = $found_table;
|
||||||
|
unset($tab_left[$found_table]);
|
||||||
|
}
|
||||||
|
} // end while
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
} // end of the "PMA_getRelatives()" function
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@@ -52,23 +52,11 @@ require_once './libraries/common.inc.php';
|
|||||||
*
|
*
|
||||||
* @uses $GLOBALS['controllink'] to close it
|
* @uses $GLOBALS['controllink'] to close it
|
||||||
* @uses $GLOBALS['userlink'] to close it
|
* @uses $GLOBALS['userlink'] to close it
|
||||||
* @uses PMA_DBI_close()
|
|
||||||
* @access private only to be used in navigation.php
|
* @access private only to be used in navigation.php
|
||||||
*/
|
*/
|
||||||
function PMA_exitNavigationFrame()
|
function PMA_exitNavigationFrame()
|
||||||
{
|
{
|
||||||
echo '</body></html>';
|
echo '</body></html>';
|
||||||
|
|
||||||
/**
|
|
||||||
* Close MySQL connections
|
|
||||||
*/
|
|
||||||
if (isset($GLOBALS['controllink']) && $GLOBALS['controllink']) {
|
|
||||||
@PMA_DBI_close($GLOBALS['controllink']);
|
|
||||||
}
|
|
||||||
if (isset($GLOBALS['userlink']) && $GLOBALS['userlink']) {
|
|
||||||
@PMA_DBI_close($GLOBALS['userlink']);
|
|
||||||
}
|
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -264,15 +264,3 @@ if (! empty($_sql_history)
|
|||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* Close MySql connections
|
|
||||||
*/
|
|
||||||
if (! empty($controllink)) {
|
|
||||||
PMA_DBI_close($controllink);
|
|
||||||
}
|
|
||||||
if (! empty($userlink)) {
|
|
||||||
PMA_DBI_close($userlink);
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
@@ -114,14 +114,4 @@ if (!isset($resize)) {
|
|||||||
ImageDestroy($srcImage);
|
ImageDestroy($srcImage);
|
||||||
ImageDestroy($destImage);
|
ImageDestroy($destImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Close MySql non-persistent connections
|
|
||||||
*/
|
|
||||||
if (isset($GLOBALS['controllink']) && $GLOBALS['controllink']) {
|
|
||||||
@PMA_DBI_close($GLOBALS['controllink']);
|
|
||||||
}
|
|
||||||
if (isset($GLOBALS['userlink']) && $GLOBALS['userlink']) {
|
|
||||||
@PMA_DBI_close($GLOBALS['userlink']);
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
|
Reference in New Issue
Block a user