From: <on...@us...> - 2002-09-18 11:00:30
|
Update of /cvsroot/xoops/xoops-current/html/class In directory usw-pr-cvs1:/tmp/cvs-serv27147 Modified Files: mysql.php database.php Log Message: no message Index: mysql.php =================================================================== RCS file: /cvsroot/xoops/xoops-current/html/class/mysql.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** mysql.php 21 Aug 2002 00:23:30 -0000 1.2 --- mysql.php 18 Sep 2002 11:00:23 -0000 1.3 *************** *** 31,57 **** function &getInstance(){ ! if ( isset($GLOBALS['xoopsDB']) && get_class($GLOBALS['xoopsDB']) == "database" ){ ! return $GLOBALS['xoopsDB']; } ! return new Database(); } ! function connect($host, $user, $password, $db, $persistent=1) { ! if ( $persistent ) { ! $this->conn = @mysql_pconnect($host, $user, $password); } else { ! $this->conn = @mysql_connect($host, $user, $password); } ! if ( !$this->conn ) { ! return false; ! //print("<b>Error Connecting DB</b>: ".$this->error($this->conn).":".$this->errno($this->conn)); } ! $selDB = mysql_select_db($db); ! if ( !$selDB ) { ! return false; ! //print("<b>Error Selecting DB</b>: ".$this->errno($this->conn).":".$this->error($this->conn)); } - return true; } --- 31,57 ---- function &getInstance(){ ! static $instance; ! if (!isset($instance)) { ! $instance = new Database(); ! $instance->setLogger(XoopsLogger::getInstance()); ! $instance->connect(); } ! return $instance; } ! function connect() { ! if (XOOPS_DB_PCONNECT == 1) { ! $this->conn = @mysql_pconnect(XOOPS_DB_HOST, XOOPS_DB_USER, XOOPS_DB_PASS); } else { ! $this->conn = @mysql_connect(XOOPS_DB_HOST, XOOPS_DB_USER, XOOPS_DB_PASS); } ! if (!$this->conn) { ! $this->logger->addQuery($sql, $this->error(), $this->errno()); } ! $selDB = mysql_select_db(XOOPS_DB_NAME); ! if (!$selDB) { ! $this->logger->addQuery($sql, $this->error(), $this->errno()); } } *************** *** 97,111 **** $start = 0; } ! $sql = $sql. " LIMIT ".intval($start).",".intval($limit).""; } $result =& mysql_query($sql, $this->conn); if ( $result ) { return $result; } else { ! if ( $this->debug ) { ! $errorMsg = @mysql_error($this->conn); ! $errorNum = @mysql_errno($this->conn); ! print( "<b>MySQL Query Error</b>: " . htmlentities( $sql ) . "<br /><b> Error number:</b>" . $errorNum . "<br /><b> Error message:</b> ". $errorMsg ."<br />" ); ! } return false; } --- 97,108 ---- $start = 0; } ! $sql = $sql. ' LIMIT '.intval($start).', '.intval($limit); } $result =& mysql_query($sql, $this->conn); if ( $result ) { + $this->logger->addQuery($sql); return $result; } else { ! $this->logger->addQuery($sql, $this->error(), $this->errno()); return false; } *************** *** 113,153 **** function &query($sql, $limit=0, $start=0) { - //echo $sql."<br />"; if ( !empty($limit) ) { if ( empty($start) ) { $start = 0; } ! $sql = $sql. " LIMIT ".intval($start).",".intval($limit).""; } $result =& $this->my_mysql_query($sql); if ( $result ) { return $result; } else { ! if ( $this->debug ) { ! $errorMsg = @mysql_error($this->conn); ! $errorNum = @mysql_errno($this->conn); ! print( "<b>MySQL Query Error</b>: " . htmlentities( $sql ) . "<br /><b> Error number:</b>" . $errorNum . "<br /><b> Error message:</b> ". $errorMsg ."<br />" ); ! } return false; } } ! function my_mysql_query($sql) { if (preg_match("/^SELECT.*/i", $sql)) { ! $Query_ID = @mysql_query($sql, $this->conn); ! return $Query_ID; } - if (isPost()) { } else { return 0; ! } ! if (myRefererCheck($errstr)) { ! $Query_ID = @mysql_query($sql, $this->conn); } else { return 0; ! } ! return $Query_ID; } --- 110,142 ---- function &query($sql, $limit=0, $start=0) { if ( !empty($limit) ) { if ( empty($start) ) { $start = 0; } ! $sql = $sql. ' LIMIT '.intval($start).', '.intval($limit); } $result =& $this->my_mysql_query($sql); if ( $result ) { + $this->logger->addQuery($sql); return $result; } else { ! $this->logger->addQuery($sql, $this->error(), $this->errno()); return false; } } ! function &my_mysql_query($sql) { if (preg_match("/^SELECT.*/i", $sql)) { ! return @mysql_query($sql, $this->conn); } if (isPost()) { } else { return 0; ! } if (myRefererCheck($errstr)) { ! return @mysql_query($sql, $this->conn); } else { return 0; ! } } Index: database.php =================================================================== RCS file: /cvsroot/xoops/xoops-current/html/class/database.php,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** database.php 15 Jul 2002 08:13:09 -0000 1.1.1.1 --- database.php 18 Sep 2002 11:00:24 -0000 1.2 *************** *** 22,27 **** class AbsDatabase { ! var $prefix; ! var $debug = false; function AbsDatabase(){ --- 22,27 ---- class AbsDatabase { ! var $prefix = ''; ! var $logger; function AbsDatabase(){ *************** *** 29,32 **** --- 29,36 ---- } + function setLogger(&$logger){ + $this->logger =& $logger; + } + function setPrefix($value) { $this->prefix = $value; *************** *** 38,49 **** } else { return $this->prefix; - } - } - - function setDebug($flag=true) { - if ( $flag ) { - $this->debug = true; - } else { - $this->debug = false; } } --- 42,45 ---- |