adodb 최신버전으로 변경

<? 를 <?php 로 변경
This commit is contained in:
2018-01-11 19:28:35 +09:00
parent feff33715f
commit 7b3b674dee
450 changed files with 19425 additions and 32248 deletions
+186 -186
View File
@@ -1,19 +1,21 @@
<?php
/*
V5.09 25 June 2009 (c) 2000-2009 John Lim (jlim#natsoft.com). 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.
/*
@version v5.20.9 21-Dec-2016
@copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
@copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
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.
Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net
Library for basic performance monitoring and tuning.
My apologies if you see code mixed with presentation. The presentation suits
my needs. If you want to separate code from presentation, be my guest. Patches
are welcome.
*/
if (!defined('ADODB_DIR')) include_once(dirname(__FILE__).'/adodb.inc.php');
@@ -31,23 +33,23 @@ function adodb_getmem()
{
if (function_exists('memory_get_usage'))
return (integer) ((memory_get_usage()+512)/1024);
$pid = getmypid();
if ( strncmp(strtoupper(PHP_OS),'WIN',3)==0) {
$output = array();
exec('tasklist /FI "PID eq ' . $pid. '" /FO LIST', $output);
exec('tasklist /FI "PID eq ' . $pid. '" /FO LIST', $output);
return substr($output[5], strpos($output[5], ':') + 1);
}
}
/* Hopefully UNIX */
exec("ps --pid $pid --no-headers -o%mem,size", $output);
if (sizeof($output) == 0) return 0;
$memarr = explode(' ',$output[0]);
if (sizeof($memarr)>=2) return (integer) $memarr[1];
return 0;
}
@@ -74,7 +76,7 @@ function adodb_log_sql(&$connx,$sql,$inputarr)
if (!empty($connx->_logsql) && (empty($connx->_logsqlErrors) || !$rs)) {
global $ADODB_LOG_CONN;
if (!empty($ADODB_LOG_CONN)) {
$conn = $ADODB_LOG_CONN;
if ($conn->databaseType != $connx->databaseType)
@@ -85,12 +87,12 @@ function adodb_log_sql(&$connx,$sql,$inputarr)
$conn = $connx;
$prefix = '';
}
$conn->_logsql = false; // disable logsql error simulation
$dbT = $conn->databaseType;
$time = $a1 - $a0;
if (!$rs) {
$errM = $connx->ErrorMsg();
$errN = $connx->ErrorNo();
@@ -102,7 +104,7 @@ function adodb_log_sql(&$connx,$sql,$inputarr)
$errN = 0;
$dbg = $conn->debug;
$conn->debug = false;
if (!is_object($rs) || $rs->dataProvider == 'empty')
if (!is_object($rs) || $rs->dataProvider == 'empty')
$conn->_affected = $conn->affected_rows(true);
$conn->lastInsID = @$conn->Insert_ID();
$conn->debug = $dbg;
@@ -110,12 +112,12 @@ function adodb_log_sql(&$connx,$sql,$inputarr)
if (isset($_SERVER['HTTP_HOST'])) {
$tracer .= '<br>'.$_SERVER['HTTP_HOST'];
if (isset($_SERVER['PHP_SELF'])) $tracer .= htmlspecialchars($_SERVER['PHP_SELF']);
} else
} else
if (isset($_SERVER['PHP_SELF'])) $tracer .= '<br>'.htmlspecialchars($_SERVER['PHP_SELF']);
//$tracer .= (string) adodb_backtrace(false);
$tracer = (string) substr($tracer,0,500);
if (is_array($inputarr)) {
if (is_array(reset($inputarr))) $params = 'Array sizeof='.sizeof($inputarr);
else {
@@ -132,7 +134,7 @@ function adodb_log_sql(&$connx,$sql,$inputarr)
} else {
$params = '';
}
if (is_array($sql)) $sql = $sql[0];
if ($prefix) $sql = $prefix.$sql;
$arr = array('b'=>strlen($sql).'.'.crc32($sql),
@@ -140,7 +142,7 @@ function adodb_log_sql(&$connx,$sql,$inputarr)
//var_dump($arr);
$saved = $conn->debug;
$conn->debug = 0;
$d = $conn->sysTimeStamp;
if (empty($d)) $d = date("'Y-m-d H:i:s'");
if ($conn->dataProvider == 'oci8' && $dbT != 'oci8po') {
@@ -153,7 +155,7 @@ function adodb_log_sql(&$connx,$sql,$inputarr)
$sql2 = $conn->qstr($arr['c']);
$params = $conn->qstr($arr['d']);
$tracer = $conn->qstr($arr['e']);
$isql = "insert into $perf_table (created,sql0,sql1,params,tracer,timer) values($d,$sql1,$sql2,$params,$tracer,$timer)";
if ($dbT == 'informix') $isql = str_replace(chr(10),' ',$isql);
$arr = false;
@@ -161,17 +163,17 @@ function adodb_log_sql(&$connx,$sql,$inputarr)
if ($dbT == 'db2') $arr['f'] = (float) $arr['f'];
$isql = "insert into $perf_table (created,sql0,sql1,params,tracer,timer) values( $d,?,?,?,?,?)";
}
global $ADODB_PERF_MIN;
if ($errN != 0 || $time >= $ADODB_PERF_MIN) {
$ok = $conn->Execute($isql,$arr);
} else
$ok = true;
$conn->debug = $saved;
if ($ok) {
$conn->_logsql = true;
$conn->_logsql = true;
} else {
$err2 = $conn->ErrorMsg();
$conn->_logsql = true; // enable logsql error simulation
@@ -181,7 +183,7 @@ function adodb_log_sql(&$connx,$sql,$inputarr)
} else {
$ok = $conn->Execute("create table $perf_table (
created varchar(50),
sql0 varchar(250),
sql0 varchar(250),
sql1 varchar(4000),
params varchar(3000),
tracer varchar(500),
@@ -194,12 +196,12 @@ function adodb_log_sql(&$connx,$sql,$inputarr)
}
$connx->_errorMsg = $errM;
$connx->_errorCode = $errN;
}
}
$connx->fnExecute = 'adodb_log_sql';
return $rs;
}
/*
The settings data structure is an associative array that database parameter per element.
@@ -207,9 +209,9 @@ Each database parameter element in the array is itself an array consisting of:
0: category code, used to group related db parameters
1: either
a. sql string to retrieve value, eg. "select value from v\$parameter where name='db_block_size'",
a. sql string to retrieve value, eg. "select value from v\$parameter where name='db_block_size'",
b. array holding sql string and field to look for, e.g. array('show variables','table_cache'),
c. a string prefixed by =, then a PHP method of the class is invoked,
c. a string prefixed by =, then a PHP method of the class is invoked,
e.g. to invoke $this->GetIndexValue(), set this array element to '=GetIndexValue',
2: description of the database parameter
*/
@@ -224,11 +226,11 @@ class adodb_perf {
var $cliFormat = "%32s => %s \r\n";
var $sql1 = 'sql1'; // used for casting sql1 to text for mssql
var $explain = true;
var $helpurl = "<a href=http://phplens.com/adodb/reference.functions.fnexecute.and.fncacheexecute.properties.html#logsql>LogSQL help</a>";
var $helpurl = '<a href="http://adodb.sourceforge.net/docs-adodb.htm#logsql">LogSQL help</a>';
var $createTableSQL = false;
var $maxLength = 2000;
// Sets the tablename to be used
// Sets the tablename to be used
static function table($newtable = false)
{
static $_table;
@@ -263,20 +265,20 @@ processes 69293
if (PHP_VERSION == '5.0.2') return false;
if (PHP_VERSION == '5.0.3') return false;
if (PHP_VERSION == '4.3.10') return false; # see http://bugs.php.net/bug.php?id=31737
static $FAIL = false;
if ($FAIL) return false;
$objName = "winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\CIMV2";
$objName = "winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\CIMV2";
$myQuery = "SELECT * FROM Win32_PerfFormattedData_PerfOS_Processor WHERE Name = '_Total'";
try {
@$objWMIService = new COM($objName);
if (!$objWMIService) {
$FAIL = true;
return false;
}
$info[0] = -1;
$info[1] = 0;
$info[2] = 0;
@@ -284,23 +286,23 @@ processes 69293
foreach($objWMIService->ExecQuery($myQuery) as $objItem) {
$info[0] = $objItem->PercentProcessorTime();
}
} catch(Exception $e) {
$FAIL = true;
echo $e->getMessage();
return false;
}
return $info;
}
// Algorithm - Steve Blinch (BlitzAffe Online, http://www.blitzaffe.com)
$statfile = '/proc/stat';
if (!file_exists($statfile)) return false;
$fd = fopen($statfile,"r");
if (!$fd) return false;
$statinfo = explode("\n",fgets($fd, 1024));
fclose($fd);
foreach($statinfo as $line) {
@@ -311,11 +313,11 @@ processes 69293
return $info;
}
}
return false;
}
/* NOT IMPLEMENTED */
function MemInfo()
{
@@ -343,8 +345,8 @@ SwapFree: 2085664 kB
Committed_AS: 348732 kB
*/
}
/*
Remember that this is client load, not db server load!
*/
@@ -353,7 +355,7 @@ Committed_AS: 348732 kB
{
$info = $this->_CPULoad();
if (!$info) return false;
if (strncmp(PHP_OS,'WIN',3)==0) {
return (integer) $info[0];
}else {
@@ -362,38 +364,38 @@ Committed_AS: 348732 kB
$this->_lastLoad = $info;
$info = $this->_CPULoad();
}
$last = $this->_lastLoad;
$this->_lastLoad = $info;
$d_user = $info[0] - $last[0];
$d_nice = $info[1] - $last[1];
$d_system = $info[2] - $last[2];
$d_idle = $info[3] - $last[3];
//printf("Delta - User: %f Nice: %f System: %f Idle: %f<br>",$d_user,$d_nice,$d_system,$d_idle);
$total=$d_user+$d_nice+$d_system+$d_idle;
if ($total<1) $total=1;
return 100*($d_user+$d_nice+$d_system)/$total;
return 100*($d_user+$d_nice+$d_system)/$total;
}
}
function Tracer($sql)
{
$perf_table = adodb_perf::table();
$saveE = $this->conn->fnExecute;
$this->conn->fnExecute = false;
global $ADODB_FETCH_MODE;
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
$sqlq = $this->conn->qstr($sql);
$arr = $this->conn->GetArray(
"select count(*),tracer
from $perf_table where sql1=$sqlq
"select count(*),tracer
from $perf_table where sql1=$sqlq
group by tracer
order by 1 desc");
$s = '';
@@ -403,26 +405,26 @@ Committed_AS: 348732 kB
$s .= sprintf("%4d",$k[0]).' &nbsp; '.strip_tags($k[1]).'<br>';
}
}
if (isset($savem)) $this->conn->SetFetchMode($savem);
$ADODB_CACHE_MODE = $save;
$this->conn->fnExecute = $saveE;
return $s;
}
/*
/*
Explain Plan for $sql.
If only a snippet of the $sql is passed in, then $partial will hold the crc32 of the
If only a snippet of the $sql is passed in, then $partial will hold the crc32 of the
actual sql.
*/
function Explain($sql,$partial=false)
{
{
return false;
}
function InvalidSQL($numsql = 10)
{
if (isset($_GET['sql'])) return;
$s = '<h3>Invalid SQL</h3>';
$saveE = $this->conn->fnExecute;
@@ -434,30 +436,30 @@ Committed_AS: 348732 kB
$s .= rs2html($rs,false,false,false,false);
} else
return "<p>$this->helpurl. ".$this->conn->ErrorMsg()."</p>";
return $s;
}
/*
This script identifies the longest running SQL
*/
*/
function _SuspiciousSQL($numsql = 10)
{
global $ADODB_FETCH_MODE;
$perf_table = adodb_perf::table();
$saveE = $this->conn->fnExecute;
$this->conn->fnExecute = false;
if (isset($_GET['exps']) && isset($_GET['sql'])) {
$partial = !empty($_GET['part']);
echo "<a name=explain></a>".$this->Explain($_GET['sql'],$partial)."\n";
}
if (isset($_GET['sql'])) return;
$sql1 = $this->sql1;
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
@@ -472,7 +474,7 @@ Committed_AS: 348732 kB
if (isset($savem)) $this->conn->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
$this->conn->fnExecute = $saveE;
if (!$rs) return "<p>$this->helpurl. ".$this->conn->ErrorMsg()."</p>";
$s = "<h3>Suspicious SQL</h3>
<font size=1>The following SQL have high average execution times</font><br>
@@ -496,15 +498,15 @@ Committed_AS: 348732 kB
$rs->MoveNext();
}
return $s."</table>";
}
function CheckMemory()
{
return '';
}
function SuspiciousSQL($numsql=10)
{
return adodb_perf::_SuspiciousSQL($numsql);
@@ -515,32 +517,32 @@ Committed_AS: 348732 kB
return adodb_perf::_ExpensiveSQL($numsql);
}
/*
This reports the percentage of load on the instance due to the most
expensive few SQL statements. Tuning these statements can often
make huge improvements in overall system performance.
This reports the percentage of load on the instance due to the most
expensive few SQL statements. Tuning these statements can often
make huge improvements in overall system performance.
*/
function _ExpensiveSQL($numsql = 10)
{
global $ADODB_FETCH_MODE;
$perf_table = adodb_perf::table();
$saveE = $this->conn->fnExecute;
$this->conn->fnExecute = false;
if (isset($_GET['expe']) && isset($_GET['sql'])) {
$partial = !empty($_GET['part']);
echo "<a name=explain></a>".$this->Explain($_GET['sql'],$partial)."\n";
}
if (isset($_GET['sql'])) return;
$sql1 = $this->sql1;
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
$rs = $this->conn->SelectLimit(
"select sum(timer) as total,$sql1,count(*),max(timer) as max_timer,min(timer) as min_timer
from $perf_table
@@ -576,7 +578,7 @@ Committed_AS: 348732 kB
}
return $s."</table>";
}
/*
Raw function to return parameter value from $settings.
*/
@@ -586,7 +588,7 @@ Committed_AS: 348732 kB
$sql = $this->settings[$param][1];
return $this->_DBParameter($sql);
}
/*
Raw function returning array of poll paramters
*/
@@ -598,7 +600,7 @@ Committed_AS: 348732 kB
$arr[3] = (integer) $this->DBParameter('current connections');
return $arr;
}
/*
Low-level Get Database Parameter
*/
@@ -607,7 +609,7 @@ Committed_AS: 348732 kB
$savelog = $this->conn->LogSQL(false);
if (is_array($sql)) {
global $ADODB_FETCH_MODE;
$sql1 = $sql[0];
$key = $sql[1];
if (sizeof($sql)>2) $pos = $sql[2];
@@ -618,9 +620,9 @@ Committed_AS: 348732 kB
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
$rs = $this->conn->Execute($sql1);
if (isset($savem)) $this->conn->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
if ($rs) {
@@ -645,21 +647,21 @@ Committed_AS: 348732 kB
$sql = str_replace('$DATABASE',$this->conn->database,$sql);
$ret = $this->conn->GetOne($sql);
$this->conn->LogSQL($savelog);
return $ret;
}
}
/*
Warn if cache ratio falls below threshold. Displayed in "Description" column.
*/
function WarnCacheRatio($val)
{
if ($val < $this->warnRatio)
if ($val < $this->warnRatio)
return '<font color=red><b>Cache ratio should be at least '.$this->warnRatio.'%</b></font>';
else return '';
}
function clearsql()
{
$perf_table = adodb_perf::table();
@@ -669,54 +671,54 @@ Committed_AS: 348732 kB
// HIGH LEVEL UI FUNCTIONS
/***********************************************************************************************/
function UI($pollsecs=5)
{
global $ADODB_LOG_CONN;
$perf_table = adodb_perf::table();
$conn = $this->conn;
$app = $conn->host;
if ($conn->host && $conn->database) $app .= ', db=';
$app .= $conn->database;
if ($app) $app .= ', ';
$savelog = $this->conn->LogSQL(false);
$savelog = $this->conn->LogSQL(false);
$info = $conn->ServerInfo();
if (isset($_GET['clearsql'])) {
$this->clearsql();
}
$this->conn->LogSQL($savelog);
// magic quotes
if (isset($_GET['sql']) && get_magic_quotes_gpc()) {
$_GET['sql'] = $_GET['sql'] = str_replace(array("\\'",'\"'),array("'",'"'),$_GET['sql']);
}
if (!isset($_SESSION['ADODB_PERF_SQL'])) $nsql = $_SESSION['ADODB_PERF_SQL'] = 10;
else $nsql = $_SESSION['ADODB_PERF_SQL'];
$app .= $info['description'];
if (isset($_GET['do'])) $do = $_GET['do'];
else if (isset($_POST['do'])) $do = $_POST['do'];
else if (isset($_GET['sql'])) $do = 'viewsql';
else $do = 'stats';
if (isset($_GET['nsql'])) {
if ($_GET['nsql'] > 0) $nsql = $_SESSION['ADODB_PERF_SQL'] = (integer) $_GET['nsql'];
}
echo "<title>ADOdb Performance Monitor on $app</title><body bgcolor=white>";
if ($do == 'viewsql') $form = "<td><form># SQL:<input type=hidden value=viewsql name=do> <input type=text size=4 name=nsql value=$nsql><input type=submit value=Go></td></form>";
else $form = "<td>&nbsp;</td>";
$allowsql = !defined('ADODB_PERF_NO_RUN_SQL');
global $ADODB_PERF_MIN;
$app .= " (Min sql timing \$ADODB_PERF_MIN=$ADODB_PERF_MIN secs)";
if (empty($_GET['hidem']))
echo "<table border=1 width=100% bgcolor=lightyellow><tr><td colspan=2>
<b><a href=http://adodb.sourceforge.net/?perf=1>ADOdb</a> Performance Monitor</b> <font size=1>for $app</font></tr><tr><td>
@@ -726,7 +728,7 @@ Committed_AS: 348732 kB
"$form",
"</tr></table>";
switch ($do) {
default:
case 'stats':
@@ -734,21 +736,21 @@ Committed_AS: 348732 kB
echo "<p>&nbsp; <a href=\"?do=viewsql&clearsql=1\">Clear SQL Log</a><br>";
echo $this->HealthCheck();
//$this->conn->debug=1;
echo $this->CheckMemory();
echo $this->CheckMemory();
break;
case 'poll':
$self = htmlspecialchars($_SERVER['PHP_SELF']);
echo "<iframe width=720 height=80%
echo "<iframe width=720 height=80%
src=\"{$self}?do=poll2&hidem=1\"></iframe>";
break;
case 'poll2':
echo "<pre>";
$this->Poll($pollsecs);
break;
case 'dosql':
if (!$allowsql) break;
$this->DoSQLForm();
break;
case 'viewsql':
@@ -758,13 +760,13 @@ Committed_AS: 348732 kB
echo($this->ExpensiveSQL($nsql));
echo($this->InvalidSQL($nsql));
break;
case 'tables':
case 'tables':
echo $this->Tables(); break;
}
global $ADODB_vers;
echo "<p><div align=center><font size=1>$ADODB_vers Sponsored by <a href=http://phplens.com/>phpLens</a></font></div>";
}
/*
Runs in infinite loop, returning real-time statistics
*/
@@ -781,12 +783,12 @@ Committed_AS: 348732 kB
while (1) {
$arr = $this->PollParameters();
$hits = sprintf('%2.2f',$arr[0]);
$reads = sprintf('%12.4f',($arr[1]-$arro[1])/$secs);
$writes = sprintf('%12.4f',($arr[2]-$arro[2])/$secs);
$sess = sprintf('%5d',$arr[3]);
$load = $this->CPULoad();
if ($load !== false) {
$oslabel = 'WS-CPU%';
@@ -795,18 +797,18 @@ Committed_AS: 348732 kB
$oslabel = '';
$osval = '';
}
if ($cnt % 10 == 0) echo " Time ".$oslabel." Hit% Sess Reads/s Writes/s\n";
if ($cnt % 10 == 0) echo " Time ".$oslabel." Hit% Sess Reads/s Writes/s\n";
$cnt += 1;
echo date('H:i:s').' '.$osval."$hits $sess $reads $writes\n";
flush();
if (connection_aborted()) return;
sleep($secs);
$arro = $arr;
}
}
/*
Returns basic health check in a command line interface
*/
@@ -814,48 +816,48 @@ Committed_AS: 348732 kB
{
return $this->HealthCheck(true);
}
/*
Returns basic health check as HTML
*/
function HealthCheck($cli=false)
{
$saveE = $this->conn->fnExecute;
$this->conn->fnExecute = false;
$this->conn->fnExecute = false;
if ($cli) $html = '';
else $html = $this->table.'<tr><td colspan=3><h3>'.$this->conn->databaseType.'</h3></td></tr>'.$this->titles;
$oldc = false;
$bgc = '';
foreach($this->settings as $name => $arr) {
if ($arr === false) break;
if (!is_string($name)) {
if ($cli) $html .= " -- $arr -- \n";
else $html .= "<tr bgcolor=$this->color><td colspan=3><i>$arr</i> &nbsp;</td></tr>";
continue;
}
if (!is_array($arr)) break;
$category = $arr[0];
$how = $arr[1];
if (sizeof($arr)>2) $desc = $arr[2];
else $desc = ' &nbsp; ';
if ($category == 'HIDE') continue;
$val = $this->_DBParameter($how);
if ($desc && strncmp($desc,"=",1) === 0) {
$fn = substr($desc,1);
$desc = $this->$fn($val);
}
if ($val === false) {
$m = $this->conn->ErrorMsg();
$val = "Error: $m";
$val = "Error: $m";
} else {
if (is_numeric($val) && $val >= 256*1024) {
if ($val % (1024*1024) == 0) {
@@ -876,34 +878,34 @@ Committed_AS: 348732 kB
if (strlen($val)==0) $val = '&nbsp;';
if ($cli) {
$html .= str_replace('&nbsp;','',sprintf($this->cliFormat,strip_tags($name),strip_tags($val),strip_tags($desc)));
}else {
$html .= "<tr$bgc><td>".$name.'</td><td>'.$val.'</td><td>'.$desc."</td></tr>\n";
}
}
if (!$cli) $html .= "</table>\n";
$this->conn->fnExecute = $saveE;
return $html;
return $html;
}
function Tables($orderby='1')
{
if (!$this->tablesSQL) return false;
$savelog = $this->conn->LogSQL(false);
$rs = $this->conn->Execute($this->tablesSQL.' order by '.$orderby);
$this->conn->LogSQL($savelog);
$html = rs2html($rs,false,false,false,false);
return $html;
}
function CreateLogTable()
{
if (!$this->createTableSQL) return false;
$table = $this->table();
$sql = str_replace('adodb_logsql',$table,$this->createTableSQL);
$savelog = $this->conn->LogSQL(false);
@@ -911,17 +913,17 @@ Committed_AS: 348732 kB
$this->conn->LogSQL($savelog);
return ($ok) ? true : false;
}
function DoSQLForm()
{
$PHP_SELF = htmlspecialchars($_SERVER['PHP_SELF']);
$sql = isset($_REQUEST['sql']) ? $_REQUEST['sql'] : '';
if (isset($_SESSION['phplens_sqlrows'])) $rows = $_SESSION['phplens_sqlrows'];
else $rows = 3;
if (isset($_REQUEST['SMALLER'])) {
$rows /= 2;
if ($rows < 3) $rows = 3;
@@ -931,7 +933,7 @@ Committed_AS: 348732 kB
$rows *= 2;
$_SESSION['phplens_sqlrows'] = $rows;
}
?>
<form method="POST" action="<?php echo $PHP_SELF ?>">
@@ -950,7 +952,7 @@ Committed_AS: 348732 kB
<?php
if (!isset($_REQUEST['sql'])) return;
$sql = $this->undomq(trim($sql));
if (substr($sql,strlen($sql)-1) === ';') {
$print = true;
@@ -962,7 +964,7 @@ Committed_AS: 348732 kB
foreach($sqla as $sqls) {
if (!$sqls) continue;
if ($print) {
print "<p>".htmlspecialchars($sqls)."</p>";
flush();
@@ -988,14 +990,14 @@ Committed_AS: 348732 kB
}
} // foreach
}
function SplitSQL($sql)
{
$arr = explode(';',$sql);
return $arr;
}
function undomq($m)
function undomq($m)
{
if (get_magic_quotes_gpc()) {
// undo the damage
@@ -1006,13 +1008,13 @@ Committed_AS: 348732 kB
return $m;
}
/************************************************************************/
/**
/**
* Reorganise multiple table-indices/statistics/..
* OptimizeMode could be given by last Parameter
*
*
* @example
* <pre>
* optimizeTables( 'tableA');
@@ -1023,12 +1025,12 @@ Committed_AS: 348732 kB
* <pre>
* optimizeTables( 'tableA', 'tableB', ADODB_OPT_LOW);
* </pre>
*
*
* @param string table name of the table to optimize
* @param int mode optimization-mode
* <code>ADODB_OPT_HIGH</code> for full optimization
* <code>ADODB_OPT_HIGH</code> for full optimization
* <code>ADODB_OPT_LOW</code> for CPU-less optimization
* Default is LOW <code>ADODB_OPT_LOW</code>
* Default is LOW <code>ADODB_OPT_LOW</code>
* @author Markus Staab
* @return Returns <code>true</code> on success and <code>false</code> on error
*/
@@ -1036,52 +1038,52 @@ Committed_AS: 348732 kB
{
$args = func_get_args();
$numArgs = func_num_args();
if ( $numArgs == 0) return false;
$mode = ADODB_OPT_LOW;
$mode = ADODB_OPT_LOW;
$lastArg = $args[ $numArgs - 1];
if ( !is_string($lastArg)) {
$mode = $lastArg;
unset( $args[ $numArgs - 1]);
}
foreach( $args as $table) {
$this->optimizeTable( $table, $mode);
}
}
/**
/**
* Reorganise the table-indices/statistics/.. depending on the given mode.
* Default Implementation throws an error.
*
*
* @param string table name of the table to optimize
* @param int mode optimization-mode
* <code>ADODB_OPT_HIGH</code> for full optimization
* <code>ADODB_OPT_HIGH</code> for full optimization
* <code>ADODB_OPT_LOW</code> for CPU-less optimization
* Default is LOW <code>ADODB_OPT_LOW</code>
* Default is LOW <code>ADODB_OPT_LOW</code>
* @author Markus Staab
* @return Returns <code>true</code> on success and <code>false</code> on error
*/
function OptimizeTable( $table, $mode = ADODB_OPT_LOW)
function OptimizeTable( $table, $mode = ADODB_OPT_LOW)
{
ADOConnection::outp( sprintf( "<p>%s: '%s' not implemented for driver '%s'</p>", __CLASS__, __FUNCTION__, $this->conn->databaseType));
return false;
}
/**
/**
* Reorganise current database.
* Default implementation loops over all <code>MetaTables()</code> and
* Default implementation loops over all <code>MetaTables()</code> and
* optimize each using <code>optmizeTable()</code>
*
*
* @author Markus Staab
* @return Returns <code>true</code> on success and <code>false</code> on error
*/
function optimizeDatabase()
function optimizeDatabase()
{
$conn = $this->conn;
if ( !$conn) return false;
$tables = $conn->MetaTables( 'TABLES');
if ( !$tables ) return false;
@@ -1090,10 +1092,8 @@ Committed_AS: 348732 kB
return false;
}
}
return true;
}
// end hack
// end hack
}
?>