From 42e6d5c4d5c82ba3b7e3546170fc42ca5d28d4da Mon Sep 17 00:00:00 2001 From: CaMer0n <cameron@e107coders.org> Date: Sat, 30 Dec 2006 03:07:50 +0000 Subject: [PATCH] Fix for $sql2 issues with previous commit. --- class2.php | 12 ++++---- e107_handlers/mysql_class.php | 58 +++++++++++++++++++++++++++++++++-- 2 files changed, 61 insertions(+), 9 deletions(-) diff --git a/class2.php b/class2.php index b565565f2..570da137f 100644 --- a/class2.php +++ b/class2.php @@ -11,9 +11,9 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/class2.php,v $ -| $Revision: 1.4 $ -| $Date: 2006-12-07 15:41:49 $ -| $Author: sweetas $ +| $Revision: 1.5 $ +| $Date: 2006-12-30 03:07:49 $ +| $Author: e107coders $ +----------------------------------------------------------------------------+ */ // @@ -227,14 +227,14 @@ define("MPREFIX", $mySQLprefix); e107_require_once(e_HANDLER."mysql_class.php"); $sql =& new db; -$sql2 =& new db; - $sql->db_SetErrorReporting(FALSE); $sql->db_Mark_Time('Start: SQL Connect'); $merror=$sql->db_Connect($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb); +$sql2 =& new db; // create after the initial connection. $sql->db_Mark_Time('Start: Prefs, misc tables'); + require_once(e_HANDLER.'admin_log_class.php'); $admin_log = new e_admin_log(); @@ -1589,7 +1589,7 @@ class error_handler { if($index == 0) { $index = 1; } else { $index = 0; } } } else { - foreach ($this->errors as $key => $value) + foreach ($this->errors as $key => $value) { $ret .= "<tr class='forumheader3'><td>{$value['short']}</td></tr>\n"; } diff --git a/e107_handlers/mysql_class.php b/e107_handlers/mysql_class.php index 303440fa2..0067ec1a5 100644 --- a/e107_handlers/mysql_class.php +++ b/e107_handlers/mysql_class.php @@ -12,8 +12,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_handlers/mysql_class.php,v $ -| $Revision: 1.3 $ -| $Date: 2006-12-30 01:11:49 $ +| $Revision: 1.4 $ +| $Date: 2006-12-30 03:07:50 $ | $Author: e107coders $ +----------------------------------------------------------------------------+ */ @@ -27,7 +27,7 @@ $db_mySQLQueryCount = 0; // Global total number of db object queries (all db's) * MySQL Abstraction class * * @package e107 -* @version $Revision: 1.3 $ +* @version $Revision: 1.4 $ * @author $Author: e107coders $ */ class db { @@ -174,6 +174,12 @@ class db { $this->db_Write_log($log_type, $log_remark, $query); } + if(!$this->mySQLaccess) + { + global $sql; + $this->mySQLaccess = $sql->mySQLaccess; + } + $b = microtime(); $sQryRes = is_null($rli) ? @mysql_query($query,$this->mySQLaccess) : @mysql_query($query, $rli); $e = microtime(); @@ -284,6 +290,13 @@ class db { $query = 'INSERT INTO '.MPREFIX."{$table} VALUES ({$arg})"; } + if(!$this->mySQLaccess) + { + global $sql; + $this->mySQLaccess = $sql->mySQLaccess; + } + + if ($result = $this->mySQLresult = $this->db_Query($query, NULL, 'db_Insert', $debug, $log_type, $log_remark )) { $tmp = mysql_insert_id($this->mySQLaccess); return $tmp; @@ -314,6 +327,13 @@ class db { function db_Update($table, $arg, $debug = FALSE, $log_type = '', $log_remark = '') { $table = $this->db_IsLang($table); $this->mySQLcurTable = $table; + + if(!$this->mySQLaccess) + { + global $sql; + $this->mySQLaccess = $sql->mySQLaccess; + } + if ($result = $this->mySQLresult = $this->db_Query('UPDATE '.MPREFIX.$table.' SET '.$arg, NULL, 'db_Update', $debug, $log_type, $log_remark)) { $result = mysql_affected_rows($this->mySQLaccess); return $result; @@ -400,6 +420,11 @@ class db { */ function db_Close() { global $eTraffic; + if(!$this->mySQLaccess) + { + global $sql; + $this->mySQLaccess = $sql->mySQLaccess; + } $eTraffic->BumpWho('db Close', 1); mysql_close($this->mySQLaccess); $this->dbError('dbClose'); @@ -419,6 +444,14 @@ class db { function db_Delete($table, $arg = '', $debug = FALSE, $log_type = '', $log_remark = '') { $table = $this->db_IsLang($table); $this->mySQLcurTable = $table; + + if(!$this->mySQLaccess) + { + global $sql; + $this->mySQLaccess = $sql->mySQLaccess; + } + + if (!$arg) { if ($result = $this->mySQLresult = $this->db_Query('DELETE FROM '.MPREFIX.$table, NULL, 'db_Delete', $debug, $log_type, $log_remark)) { return $result; @@ -553,6 +586,12 @@ class db { return $table; } + if(!$this->mySQLaccess) + { + global $sql; + $this->mySQLaccess = $sql->mySQLaccess; + } + if (!$mySQLtablelist) { $tablist = mysql_list_tables($this->mySQLdefaultdb,$this->mySQLaccess); while (list($temp) = mysql_fetch_array($tablist)) { @@ -686,6 +725,12 @@ class db { $convert = array("PRIMARY"=>"PRI","INDEX"=>"MUL","UNIQUE"=>"UNI"); $key = ($convert[$key]) ? $convert[$key] : "OFF"; + if(!$this->mySQLaccess) + { + global $sql; + $this->mySQLaccess = $sql->mySQLaccess; + } + $result = mysql_query("SHOW COLUMNS FROM ".MPREFIX.$table,$this->mySQLaccess); if (mysql_num_rows($result) > 0) { $c=0; @@ -727,6 +772,13 @@ class db { if ($strip) { $data = strip_if_magic($data); } + + if(!$this->mySQLaccess) + { + global $sql; + $this->mySQLaccess = $sql->mySQLaccess; + } + return mysql_real_escape_string($data,$this->mySQLaccess); } }