Ignore:
Timestamp:
06/29/07 15:17:46 (17 years ago)
Author:
niltonneto
Message:

Versão nova do ADODB (4.5 para 4.95)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/phpgwapi/inc/adodb/perf/perf-mysql.inc.php

    r2 r34  
    11<?php 
    22/*  
    3 V4.51 29 July 2004  (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved. 
     3V4.94 23 Jan 2007  (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. 
    44  Released under both BSD license and Lesser GPL library license.  
    55  Whenever there is any discrepancy between the two licenses,  
     
    133133                $save = $ADODB_FETCH_MODE; 
    134134                $ADODB_FETCH_MODE = ADODB_FETCH_NUM; 
     135                if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false); 
     136                 
    135137                $rs = $this->conn->Execute('show status'); 
     138                 
     139                if (isset($savem)) $this->conn->SetFetchMode($savem); 
    136140                $ADODB_FETCH_MODE = $save; 
    137141                 
     
    158162                $save = $ADODB_FETCH_MODE; 
    159163                $ADODB_FETCH_MODE = ADODB_FETCH_NUM; 
     164                if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false); 
     165                 
    160166                $rs = $this->conn->Execute('show status'); 
     167                 
     168                if (isset($savem)) $this->conn->SetFetchMode($savem); 
    161169                $ADODB_FETCH_MODE = $save; 
    162170                 
     
    186194                // first find out type of table 
    187195                //$this->conn->debug=1; 
     196                 
     197                global $ADODB_FETCH_MODE; 
     198                $save = $ADODB_FETCH_MODE; 
     199                $ADODB_FETCH_MODE = ADODB_FETCH_NUM; 
     200                if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false); 
     201                 
    188202                $rs = $this->conn->Execute('show table status'); 
     203                 
     204                if (isset($savem)) $this->conn->SetFetchMode($savem); 
     205                $ADODB_FETCH_MODE = $save; 
     206                 
    189207                if (!$rs) return ''; 
    190208                $type = strtoupper($rs->fields[1]); 
     
    210228                 
    211229                $total += $hits; 
    212                 if ($total) return ($hits*100)/$total; 
     230                if ($total) return round(($hits*100)/$total,2); 
    213231                return 0; 
    214232        } 
     
    228246        function GetInnoDBHitRatio() 
    229247        { 
    230         global $HTTP_SESSION_VARS; 
    231          
     248        global $ADODB_FETCH_MODE; 
     249         
     250                $save = $ADODB_FETCH_MODE; 
     251                $ADODB_FETCH_MODE = ADODB_FETCH_NUM; 
     252                if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false); 
     253                 
    232254                $rs = $this->conn->Execute('show innodb status'); 
     255                 
     256                if (isset($savem)) $this->conn->SetFetchMode($savem); 
     257                $ADODB_FETCH_MODE = $save; 
     258                 
    233259                if (!$rs || $rs->EOF) return 0; 
    234260                $stat = $rs->fields[0]; 
     
    238264                if (preg_match('!Buffer pool hit rate\s*([0-9]*) / ([0-9]*)!',$stat,$arr)) { 
    239265                        $val = 100*$arr[1]/$arr[2]; 
    240                         $HTTP_SESSION_VARS['INNODB_HIT_PCT'] = $val; 
    241                         return $val; 
     266                        $_SESSION['INNODB_HIT_PCT'] = $val; 
     267                        return round($val,2); 
    242268                } else { 
    243                         if (isset($HTTP_SESSION_VARS['INNODB_HIT_PCT'])) return $HTTP_SESSION_VARS['INNODB_HIT_PCT']; 
     269                        if (isset($_SESSION['INNODB_HIT_PCT'])) return $_SESSION['INNODB_HIT_PCT']; 
    244270                        return 0; 
    245271                } 
     
    253279                if ($reqs == 0) return 0; 
    254280                 
    255                 return ($hits/($reqs+$hits))*100; 
    256         } 
    257          
     281                return round(($hits/($reqs+$hits))*100,2); 
     282        } 
     283         
     284    // start hack  
     285    var $optimizeTableLow = 'CHECK TABLE %s FAST QUICK'; 
     286    var $optimizeTableHigh = 'OPTIMIZE TABLE %s'; 
     287     
     288    /**  
     289     * @see adodb_perf#optimizeTable 
     290     */ 
     291     function optimizeTable( $table, $mode = ADODB_OPT_LOW)  
     292     { 
     293        if ( !is_string( $table)) return false; 
     294         
     295        $conn = $this->conn; 
     296        if ( !$conn) return false; 
     297         
     298        $sql = ''; 
     299        switch( $mode) { 
     300            case ADODB_OPT_LOW : $sql = $this->optimizeTableLow; break; 
     301            case ADODB_OPT_HIGH : $sql = $this->optimizeTableHigh; break; 
     302            default :  
     303            { 
     304                // May dont use __FUNCTION__ constant for BC (__FUNCTION__ Added in PHP 4.3.0) 
     305                ADOConnection::outp( sprintf( "<p>%s: '%s' using of undefined mode '%s'</p>", __CLASS__, __FUNCTION__, $mode)); 
     306                return false; 
     307            } 
     308        } 
     309        $sql = sprintf( $sql, $table); 
     310         
     311        return $conn->Execute( $sql) !== false; 
     312     } 
     313    // end hack  
    258314} 
    259315?> 
Note: See TracChangeset for help on using the changeset viewer.