imported adodb 4.65

This commit is contained in:
Ralf Becker
2005-09-26 10:12:10 +00:00
parent e7179a8977
commit 4e5cb1786e
131 changed files with 8364 additions and 4114 deletions

View File

@ -1,6 +1,6 @@
<?php
/*
V4.52 10 Aug 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
V4.65 22 July 2005 (c) 2000-2005 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,
the BSD license will take precedence. See License.txt.
@ -132,7 +132,11 @@ class perf_mysql extends adodb_perf{
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 status');
if (isset($savem)) $this->conn->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
if (!$rs) return 0;
@ -157,7 +161,11 @@ class perf_mysql extends adodb_perf{
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 status');
if (isset($savem)) $this->conn->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
if (!$rs) return 0;
@ -185,7 +193,17 @@ class perf_mysql extends adodb_perf{
{
// 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]);
$rs->Close();
@ -209,7 +227,7 @@ class perf_mysql extends adodb_perf{
$total += $this->_DBParameter(array("show status","Qcache_not_cached"));
$total += $hits;
if ($total) return ($hits*100)/$total;
if ($total) return round(($hits*100)/$total,2);
return 0;
}
@ -227,9 +245,17 @@ class perf_mysql extends adodb_perf{
*/
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];
$rs->Close();
@ -237,10 +263,10 @@ class perf_mysql extends adodb_perf{
$stat = substr($stat,$at,200);
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;
}
return 0;
@ -252,8 +278,38 @@ class perf_mysql extends adodb_perf{
$reqs = $this->_DBParameter(array("show status","Key_reads"));
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
}
?>