note 37551 deleted from function.mysql-stat by philip
| From: | philip@php.net | Date: | Wed, 21 Jul 2004 00:36:21 +0000 |
| Subject: | note 37551 deleted from function.mysql-stat by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-73773@lists.php.net to get a copy of this message | ||
Note Submitter: gabcam@gogo.com.br
----
ex class
<?php
// connect \\
class DateBaseServer
{
var $CloseSS ;
var $ConnSQL ;
var $SlDbSQL ;
var $ConnDBs ;
var $ConnStat ;
var $DBS = array() ;
function Add($Var,$Value)
{
$this->DBS[$Var] = $Value ; }
function Connect()
{
$ConnQuery = $this->DBS['Serv'].$this->DBS['ConTp'];
$ConnSeleD = $this->DBS['Serv'].'select_db';
$this->ConnSQL =
$ConnQuery ("{$this->DBS['Host']}:{$this->DBS['Port']}",
"{$this->DBS['User']}", "{$this->DBS['Pass']}")
or die($this->DBS['Serv'].errno().':
'.$this->DBS['Serv'].error()."\n");
$this->SlDbSQL = $ConnSeleD ("{$this->DBS['DBase']}",$this->ConnSQL)
or die($this->DBS['Serv'].errno().':
'.$this->DBS['Serv'].error()."\n");
return($this->ConnSQL) ; }
function Stats($TypeStatus)
{
if($TypeStatus=='ConnGet')
{
$ConnGetS = $this->DBS['Serv'].'get_server_info' ;
$ConnGetP = $this->DBS['Serv'].'get_proto_info' ;
$ConnGetH = $this->DBS['Serv'].'get_host_info' ;
$ConnGetC = $this->DBS['Serv'].'get_client_info' ;
$ServGet[] = $this->DBS['Serv']."server version: " .$ConnGetS() ;
$ServGet[] = $this->DBS['Serv']."protocol version: ".$ConnGetP() ;
$ServGet[] = $this->DBS['Serv']."host info: " .$ConnGetH() ;
$ServGet[] = $this->DBS['Serv']."client info: " .$ConnGetC() ;
return(print_r($ServGet)) ;
}else
if($TypeStatus=='ConnStat')
{
$ConnStat = $this->DBS['Serv'].$this->DBS['Status'] ;
$Result = explode(' ',$ConnStat($this->DBS['Link'])) ;
return(print_r($Result)) ;
}else
if($TypeStatus=='ConnDBs')
{
$ConnDBs = $this->DBS['Serv'].'query' ;
$ReslBDs = $this->DBS['Serv'].'fetch_array' ;
$Result = $ConnDBs('SHOW INNODB STATUS') ;
$Result = $ReslBDs($Result) ;
$StrgBar = str_pad('',60,'-',STR_PAD_BOTH) ;
return(print($StrgBar.$Result['Status'])) ;
}else
if($TypeStatus=='ConnLst')
{
$ConnLstP = $this->DBS['Serv'].'list_processes' ;
$ConnLstA = $this->DBS['Serv'].'fetch_assoc' ;
$ConnLstF = $this->DBS['Serv'].'free_result' ;
$Results = $ConnLstP($this->DBS['Link']) ;
@$ConnLstF ($Result) ;
while ($row = $ConnLstA($Results))
{$Process[] = $row["Id"].' '.$row["Host"].'
'.$row["db"].' '.$row["Command"].'
'.$row["Time"];}
return(print_r($Process)) ;
}
}
// call class \\
$Connect = new DateBaseServer ;
$Connect->Add('Host' ,'localhost') ;
$Connect->Add('Port' ,'3306') ;
$Connect->Add('User' ,'dtbase') ;
$Connect->Add('Pass' ,'mypass') ;
$Connect->Add('DBase' ,'dtbase') ;
$Connect->Add('Serv' ,'mysql_') ; // u can change other db server (...)
$Connect->Add('ConTp' ,'connect') ;
$Connect->Add('Status' ,'stat') ;
$ConnSQL = $Connect->Connect() ;
$Connect->Add('Link',$ConnSQL) ;
?>