Index: trunk/phpgwapi/inc/adodb/perf/perf-mysql.inc.php
===================================================================
--- trunk/phpgwapi/inc/adodb/perf/perf-mysql.inc.php	(revision 2)
+++ trunk/phpgwapi/inc/adodb/perf/perf-mysql.inc.php	(revision 34)
@@ -1,5 +1,5 @@
 <?php
 /* 
-V4.51 29 July 2004  (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
+V4.94 23 Jan 2007  (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
   Released under both BSD license and Lesser GPL library license. 
   Whenever there is any discrepancy between the two licenses, 
@@ -133,5 +133,9 @@
 		$save = $ADODB_FETCH_MODE;
 		$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+		if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
+		
 		$rs = $this->conn->Execute('show status');
+		
+		if (isset($savem)) $this->conn->SetFetchMode($savem);
 		$ADODB_FETCH_MODE = $save;
 		
@@ -158,5 +162,9 @@
 		$save = $ADODB_FETCH_MODE;
 		$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+		if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
+		
 		$rs = $this->conn->Execute('show status');
+		
+		if (isset($savem)) $this->conn->SetFetchMode($savem);
 		$ADODB_FETCH_MODE = $save;
 		
@@ -186,5 +194,15 @@
 		// first find out type of table
 		//$this->conn->debug=1;
+		
+		global $ADODB_FETCH_MODE;
+		$save = $ADODB_FETCH_MODE;
+		$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+		if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
+		
 		$rs = $this->conn->Execute('show table status');
+		
+		if (isset($savem)) $this->conn->SetFetchMode($savem);
+		$ADODB_FETCH_MODE = $save;
+		
 		if (!$rs) return '';
 		$type = strtoupper($rs->fields[1]);
@@ -210,5 +228,5 @@
 		
 		$total += $hits;
-		if ($total) return ($hits*100)/$total;
+		if ($total) return round(($hits*100)/$total,2);
 		return 0;
 	}
@@ -228,7 +246,15 @@
 	function GetInnoDBHitRatio()
 	{
-	global $HTTP_SESSION_VARS;
-	
+	global $ADODB_FETCH_MODE;
+	
+		$save = $ADODB_FETCH_MODE;
+		$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+		if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
+		
 		$rs = $this->conn->Execute('show innodb status');
+		
+		if (isset($savem)) $this->conn->SetFetchMode($savem);
+		$ADODB_FETCH_MODE = $save;
+		
 		if (!$rs || $rs->EOF) return 0;
 		$stat = $rs->fields[0];
@@ -238,8 +264,8 @@
 		if (preg_match('!Buffer pool hit rate\s*([0-9]*) / ([0-9]*)!',$stat,$arr)) {
 			$val = 100*$arr[1]/$arr[2];
-			$HTTP_SESSION_VARS['INNODB_HIT_PCT'] = $val;
-			return $val;
+			$_SESSION['INNODB_HIT_PCT'] = $val;
+			return round($val,2);
 		} else {
-			if (isset($HTTP_SESSION_VARS['INNODB_HIT_PCT'])) return $HTTP_SESSION_VARS['INNODB_HIT_PCT'];
+			if (isset($_SESSION['INNODB_HIT_PCT'])) return $_SESSION['INNODB_HIT_PCT'];
 			return 0;
 		}
@@ -253,7 +279,37 @@
 		if ($reqs == 0) return 0;
 		
-		return ($hits/($reqs+$hits))*100;
-	}
-	
+		return round(($hits/($reqs+$hits))*100,2);
+	}
+	
+    // start hack 
+    var $optimizeTableLow = 'CHECK TABLE %s FAST QUICK';
+    var $optimizeTableHigh = 'OPTIMIZE TABLE %s';
+    
+    /** 
+     * @see adodb_perf#optimizeTable
+     */
+     function optimizeTable( $table, $mode = ADODB_OPT_LOW) 
+     {
+        if ( !is_string( $table)) return false;
+        
+        $conn = $this->conn;
+        if ( !$conn) return false;
+        
+        $sql = '';
+        switch( $mode) {
+            case ADODB_OPT_LOW : $sql = $this->optimizeTableLow; break;
+            case ADODB_OPT_HIGH : $sql = $this->optimizeTableHigh; break;
+            default : 
+            {
+                // May dont use __FUNCTION__ constant for BC (__FUNCTION__ Added in PHP 4.3.0)
+                ADOConnection::outp( sprintf( "<p>%s: '%s' using of undefined mode '%s'</p>", __CLASS__, __FUNCTION__, $mode));
+                return false;
+            }
+        }
+        $sql = sprintf( $sql, $table);
+        
+        return $conn->Execute( $sql) !== false;
+     }
+    // end hack 
 }
 ?>
