From: <bh...@us...> - 2008-01-10 19:15:00
|
Revision: 17353 http://gallery.svn.sourceforge.net/gallery/?rev=17353&view=rev Author: bharat Date: 2008-01-10 11:14:54 -0800 (Thu, 10 Jan 2008) Log Message: ----------- Update adodb vendor branch to 4.96a Modified Paths: -------------- branches/vendor/gallery2/lib/adodb/adodb-error.inc.php branches/vendor/gallery2/lib/adodb/adodb-iterator.inc.php branches/vendor/gallery2/lib/adodb/adodb-lib.inc.php branches/vendor/gallery2/lib/adodb/adodb-perf.inc.php branches/vendor/gallery2/lib/adodb/adodb-php4.inc.php branches/vendor/gallery2/lib/adodb/adodb-time.inc.php branches/vendor/gallery2/lib/adodb/adodb.inc.php branches/vendor/gallery2/lib/adodb/drivers/adodb-ado.inc.php branches/vendor/gallery2/lib/adodb/drivers/adodb-ado5.inc.php branches/vendor/gallery2/lib/adodb/drivers/adodb-ado_mssql.inc.php branches/vendor/gallery2/lib/adodb/drivers/adodb-db2.inc.php branches/vendor/gallery2/lib/adodb/drivers/adodb-mysql.inc.php branches/vendor/gallery2/lib/adodb/drivers/adodb-mysqli.inc.php branches/vendor/gallery2/lib/adodb/drivers/adodb-mysqlt.inc.php branches/vendor/gallery2/lib/adodb/drivers/adodb-oci8.inc.php branches/vendor/gallery2/lib/adodb/drivers/adodb-oci805.inc.php branches/vendor/gallery2/lib/adodb/drivers/adodb-oci8po.inc.php branches/vendor/gallery2/lib/adodb/drivers/adodb-oracle.inc.php branches/vendor/gallery2/lib/adodb/drivers/adodb-postgres64.inc.php branches/vendor/gallery2/lib/adodb/drivers/adodb-postgres7.inc.php branches/vendor/gallery2/lib/adodb/perf/perf-db2.inc.php branches/vendor/gallery2/lib/adodb/perf/perf-mssql.inc.php branches/vendor/gallery2/lib/adodb/perf/perf-mysql.inc.php branches/vendor/gallery2/lib/adodb/perf/perf-oci8.inc.php branches/vendor/gallery2/lib/adodb/perf/perf-postgres.inc.php Modified: branches/vendor/gallery2/lib/adodb/adodb-error.inc.php =================================================================== --- branches/vendor/gallery2/lib/adodb/adodb-error.inc.php 2008-01-10 19:07:17 UTC (rev 17352) +++ branches/vendor/gallery2/lib/adodb/adodb-error.inc.php 2008-01-10 19:14:54 UTC (rev 17353) @@ -1,6 +1,6 @@ <?php /** - * @version V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. + * @version V4.96 24 Sept 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, * the BSD license will take precedence. Modified: branches/vendor/gallery2/lib/adodb/adodb-iterator.inc.php =================================================================== --- branches/vendor/gallery2/lib/adodb/adodb-iterator.inc.php 2008-01-10 19:07:17 UTC (rev 17352) +++ branches/vendor/gallery2/lib/adodb/adodb-iterator.inc.php 2008-01-10 19:14:54 UTC (rev 17353) @@ -1,7 +1,7 @@ <?php /* - V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. + V4.96 24 Sept 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, the BSD license will take precedence. Modified: branches/vendor/gallery2/lib/adodb/adodb-lib.inc.php =================================================================== --- branches/vendor/gallery2/lib/adodb/adodb-lib.inc.php 2008-01-10 19:07:17 UTC (rev 17352) +++ branches/vendor/gallery2/lib/adodb/adodb-lib.inc.php 2008-01-10 19:14:54 UTC (rev 17353) @@ -1,5 +1,5 @@ <?php - + // security - hide paths if (!defined('ADODB_DIR')) die(); @@ -7,7 +7,7 @@ $ADODB_INCLUDED_LIB = 1; /* - @version V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim\@natsoft.com.my). All rights reserved. + @version V4.96 24 Sept 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, the BSD license will take precedence. See License.txt. @@ -16,6 +16,36 @@ Less commonly used functions are placed here to reduce size of adodb.inc.php. */ +function adodb_strip_order_by($sql) +{ + $rez = preg_match('/(\sORDER\s+BY\s[^)]*)/is',$sql,$arr); + if ($arr) + if (strpos($arr[0],'(') !== false) { + $at = strpos($sql,$arr[0]); + $cntin = 0; + for ($i=$at, $max=strlen($sql); $i < $max; $i++) { + $ch = $sql[$i]; + if ($ch == '(') { + $cntin += 1; + } elseif($ch == ')') { + $cntin -= 1; + if ($cntin < 0) { + break; + } + } + } + $sql = substr($sql,0,$at).substr($sql,$i); + } else + $sql = str_replace($arr[0], '', $sql); + return $sql; + } + +if (false) { + $sql = 'select * from (select a from b order by a(b),b(c) desc)'; + $sql = '(select * from abc order by 1)'; + die(adodb_strip_order_by($sql)); +} + function adodb_probetypes(&$array,&$types,$probe=8) { // probe and guess the type @@ -111,7 +141,10 @@ $keyCol = array($keyCol); } foreach($fieldArray as $k => $v) { - if ($autoQuote && !is_numeric($v) and strncmp($v,"'",1) !== 0 and strcasecmp($v,$zthis->null2null)!=0) { + if ($v === null) { + $v = 'NULL'; + $fieldArray[$k] = $v; + } else if ($autoQuote && !is_numeric($v) /*and strncmp($v,"'",1) !== 0 -- sql injection risk*/ and strcasecmp($v,$zthis->null2null)!=0) { $v = $zthis->qstr($v); $fieldArray[$k] = $v; } @@ -369,12 +402,12 @@ if (!empty($zthis->_nestedSQL) || preg_match("/^\s*SELECT\s+DISTINCT/is", $sql) || preg_match('/\s+GROUP\s+BY\s+/is',$sql) || preg_match('/\s+UNION\s+/is',$sql)) { + + $rewritesql = adodb_strip_order_by($sql); + // ok, has SELECT DISTINCT or GROUP BY so see if we can use a table alias // but this is only supported by oracle and postgresql... if ($zthis->dataProvider == 'oci8') { - - $rewritesql = preg_replace('/(\sORDER\s+BY\s[^)]*)/is','',$sql); - // Allow Oracle hints to be used for query optimization, Chris Wrye if (preg_match('#/\\*+.*?\\*\\/#', $sql, $hint)) { $rewritesql = "SELECT ".$hint[0]." COUNT(*) FROM (".$rewritesql.")"; @@ -382,30 +415,21 @@ $rewritesql = "SELECT COUNT(*) FROM (".$rewritesql.")"; } else if (strncmp($zthis->databaseType,'postgres',8) == 0) { - $rewritesql = preg_replace('/(\sORDER\s+BY\s[^)]*)/is','',$sql); $rewritesql = "SELECT COUNT(*) FROM ($rewritesql) _ADODB_ALIAS_"; } - } else { + } else { // now replace SELECT ... FROM with SELECT COUNT(*) FROM $rewritesql = preg_replace( '/^\s*SELECT\s.*\s+FROM\s/Uis','SELECT COUNT(*) FROM ',$sql); - - - // fix by alexander zhukov, alex#unipack.ru, because count(*) and 'order by' fails // with mssql, access and postgresql. Also a good speedup optimization - skips sorting! // also see http://phplens.com/lens/lensforum/msgs.php?id=12752 - if (preg_match('/\sORDER\s+BY\s*\(/i',$rewritesql)) - $rewritesql = preg_replace('/(\sORDER\s+BY\s.*)/is','',$rewritesql); - else - $rewritesql = preg_replace('/(\sORDER\s+BY\s[^)]*)/is','',$rewritesql); + $rewritesql = adodb_strip_order_by($rewritesql); } - - if (isset($rewritesql) && $rewritesql != $sql) { - if (preg_match('/\sLIMIT\s+[0-9]+/i',$sql,$limitarr)) $rewritesql .= $limitarr[1]; - + if (preg_match('/\sLIMIT\s+[0-9]+/i',$sql,$limitarr)) $rewritesql .= $limitarr[0]; + if ($secs2cache) { // we only use half the time of secs2cache because the count can quickly // become inaccurate if new records are added @@ -422,7 +446,7 @@ // strip off unneeded ORDER BY if no UNION if (preg_match('/\s*UNION\s*/is', $sql)) $rewritesql = $sql; - else $rewritesql = preg_replace('/(\sORDER\s+BY\s.*)/is','',$sql); + else $rewritesql = $rewritesql = adodb_strip_order_by($sql); if (preg_match('/\sLIMIT\s+[0-9]+/i',$sql,$limitarr)) $rewritesql .= $limitarr[0]; @@ -974,12 +998,14 @@ break; case "N": - $val = (float) $arrFields[$fname]; + $val = $arrFields[$fname]; + if (!is_numeric($val)) $val = str_replace(',', '.', (float)$val); break; case "I": case "R": - $val = (int) $arrFields[$fname]; + $val = $arrFields[$fname]; + if (!is_numeric($val)) $val = (integer) $val; break; default: @@ -1003,7 +1029,8 @@ if ($inputarr) { foreach($inputarr as $kk=>$vv) { if (is_string($vv) && strlen($vv)>64) $vv = substr($vv,0,64).'...'; - $ss .= "($kk=>'$vv') "; + if (is_null($vv)) $ss .= "($kk=>null) "; + else $ss .= "($kk=>'$vv') "; } $ss = "[ $ss ]"; } @@ -1144,4 +1171,4 @@ } */ -?> +?> \ No newline at end of file Modified: branches/vendor/gallery2/lib/adodb/adodb-perf.inc.php =================================================================== --- branches/vendor/gallery2/lib/adodb/adodb-perf.inc.php 2008-01-10 19:07:17 UTC (rev 17352) +++ branches/vendor/gallery2/lib/adodb/adodb-perf.inc.php 2008-01-10 19:14:54 UTC (rev 17353) @@ -1,6 +1,6 @@ <?php /* -V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. +V4.96 24 Sept 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, the BSD license will take precedence. See License.txt. @@ -640,13 +640,20 @@ else return ''; } + function clearsql() + { + $perf_table = adodb_perf::table(); + $this->conn->Execute("delete from $perf_table where created<".$this->conn->sysTimeStamp); + } + /***********************************************************************************************/ // HIGH LEVEL UI FUNCTIONS /***********************************************************************************************/ - + function UI($pollsecs=5) { + global $ADODB_LOG_CONN; $perf_table = adodb_perf::table(); $conn = $this->conn; @@ -659,7 +666,7 @@ $savelog = $this->conn->LogSQL(false); $info = $conn->ServerInfo(); if (isset($_GET['clearsql'])) { - $this->conn->Execute("delete from $perf_table"); + $this->clearsql(); } $this->conn->LogSQL($savelog); @@ -702,9 +709,13 @@ switch ($do) { default: case 'stats': + + if (empty($ADODB_LOG_CONN)) + echo "<p> <a href=\"?do=viewsql&clearsql=1\">Clear SQL Log</a><br>"; echo $this->HealthCheck(); //$this->conn->debug=1; echo $this->CheckMemory(); + global $ADODB_LOG_CONN; break; case 'poll': echo "<iframe width=720 height=80% Modified: branches/vendor/gallery2/lib/adodb/adodb-php4.inc.php =================================================================== --- branches/vendor/gallery2/lib/adodb/adodb-php4.inc.php 2008-01-10 19:07:17 UTC (rev 17352) +++ branches/vendor/gallery2/lib/adodb/adodb-php4.inc.php 2008-01-10 19:14:54 UTC (rev 17353) @@ -1,7 +1,7 @@ <?php /* - V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. + V4.96 24 Sept 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, the BSD license will take precedence. Modified: branches/vendor/gallery2/lib/adodb/adodb-time.inc.php =================================================================== --- branches/vendor/gallery2/lib/adodb/adodb-time.inc.php 2008-01-10 19:07:17 UTC (rev 17352) +++ branches/vendor/gallery2/lib/adodb/adodb-time.inc.php 2008-01-10 19:14:54 UTC (rev 17353) @@ -241,6 +241,14 @@ CHANGELOG +- 15 July 2007 0.30 +Added PHP 5.2.0 compatability fixes. + * gmtime behaviour for 1970 has changed. We use the actual date if it is between 1970 to 2038 to get the + * timezone, otherwise we use the current year as the baseline to retrieve the timezone. + * Also the timezone's in php 5.2.* support historical data better, eg. if timezone today was +8, but + in 1970 it was +7:30, then php 5.2 return +7:30, while this library will use +8. + * + - 19 March 2006 0.24 Changed strftime() locale detection, because some locales prepend the day of week to the date when %c is used. @@ -368,8 +376,10 @@ /* Version Number */ -define('ADODB_DATE_VERSION',0.24); +define('ADODB_DATE_VERSION',0.30); +$ADODB_DATETIME_CLASS = (PHP_VERSION >= 5.2); + /* This code was originally for windows. But apparently this problem happens also with Linux, RH 7.3 and later! @@ -387,10 +397,13 @@ function adodb_date_test_date($y1,$m,$d=13) { - $t = adodb_mktime(0,0,0,$m,$d,$y1); + $h = round(rand()% 24); + $t = adodb_mktime($h,0,0,$m,$d,$y1); $rez = adodb_date('Y-n-j H:i:s',$t); - if ("$y1-$m-$d 00:00:00" != $rez) { - print "<b>$y1 error, expected=$y1-$m-$d 00:00:00, adodb=$rez</b><br>"; + if ($h == 0) $h = '00'; + else if ($h < 10) $h = '0'.$h; + if ("$y1-$m-$d $h:00:00" != $rez) { + print "<b>$y1 error, expected=$y1-$m-$d $h:00:00, adodb=$rez</b><br>"; return false; } return true; @@ -403,7 +416,7 @@ if ($s1 == $s2) return true; - echo "error for $fmt, strftime=$s1, $adodb=$s2<br>"; + echo "error for $fmt, strftime=$s1, adodb=$s2<br>"; return false; } @@ -421,6 +434,15 @@ // This flag disables calling of PHP native functions, so we can properly test the code if (!defined('ADODB_TEST_DATES')) define('ADODB_TEST_DATES',1); + $t = time(); + + + $fmt = 'Y-m-d H:i:s'; + echo '<pre>'; + echo 'adodb: ',adodb_date($fmt,$t),'<br>'; + echo 'php : ',date($fmt,$t),'<br>'; + echo '</pre>'; + adodb_date_test_strftime('%Y %m %x %X'); adodb_date_test_strftime("%A %d %B %Y"); adodb_date_test_strftime("%H %M S"); @@ -480,6 +502,7 @@ // Test string formating print "<p>Testing date formating</p>"; + $fmt = '\d\a\t\e T Y-m-d H:i:s a A d D F g G h H i j l L m M n O \R\F\C2822 r s t U w y Y z Z 2003'; $s1 = date($fmt,0); $s2 = adodb_date($fmt,0); @@ -657,15 +680,45 @@ return $y; } +function adodb_get_gmt_diff_ts($ts) +{ + if (0 <= $ts && $ts <= 0x7FFFFFFF) { // check if number in 32-bit signed range) { + $arr = getdate($ts); + $y = $arr['year']; + $m = $arr['mon']; + $d = $arr['mday']; + return adodb_get_gmt_diff($y,$m,$d); +} else { + return adodb_get_gmt_diff(false,false,false); + } + +} + /** - get local time zone offset from GMT + get local time zone offset from GMT. Does not handle historical timezones before 1970. */ -function adodb_get_gmt_diff() +function adodb_get_gmt_diff($y,$m,$d) { -static $TZ; +static $TZ,$tzo; +global $ADODB_DATETIME_CLASS; + + if (!defined('ADODB_TEST_DATES')) $y = false; + else if ($y < 1970 || $y >= 2038) $y = false; + + if ($ADODB_DATETIME_CLASS && $y !== false) { + $dt = new DateTime(); + $dt->setISODate($y,$m,$d); + if (empty($tzo)) { + $tzo = new DateTimeZone(date_default_timezone_get()); + # $tzt = timezone_transitions_get( $tzo ); + } + return -$tzo->getOffset($dt); + } else { if (isset($TZ)) return $TZ; + $y = date('Y'); + $TZ = mktime(0,0,0,12,2,$y,0) - gmmktime(0,0,0,12,2,$y,0); + } - $TZ = mktime(0,0,0,1,2,1970,0) - gmmktime(0,0,0,1,2,1970,0); return $TZ; } @@ -712,8 +765,8 @@ { global $_month_table_normal,$_month_table_leaf; - if (_adodb_is_leap_year($y)) $marr =& $_month_table_leaf; - else $marr =& $_month_table_normal; + if (_adodb_is_leap_year($y)) $marr = $_month_table_leaf; + else $marr = $_month_table_normal; if ($m > 12 || $m < 1) return false; @@ -736,8 +789,7 @@ static $YRS; global $_month_table_normal,$_month_table_leaf; - $d = $origd - ($is_gmt ? 0 : adodb_get_gmt_diff()); - + $d = $origd - ($is_gmt ? 0 : adodb_get_gmt_diff_ts($origd)); $_day_power = 86400; $_hour_power = 3600; $_min_power = 60; @@ -927,7 +979,24 @@ 0 => $origd ); } +/* + if ($isphp5) + $dates .= sprintf('%s%04d',($gmt<=0)?'+':'-',abs($gmt)/36); + else + $dates .= sprintf('%s%04d',($gmt<0)?'+':'-',abs($gmt)/36); + break;*/ +function adodb_tz_offset($gmt,$isphp5) +{ + $zhrs = abs($gmt)/3600; + $hrs = floor($zhrs); + if ($isphp5) + return sprintf('%s%02d%02d',($gmt<=0)?'+':'-',floor($zhrs),($zhrs-$hrs)*60); + else + return sprintf('%s%02d%02d',($gmt<0)?'+':'-',floor($zhrs),($zhrs-$hrs)*60); + break; +} + function adodb_gmdate($fmt,$d=false) { return adodb_date($fmt,$d,true); @@ -958,6 +1027,7 @@ function adodb_date($fmt,$d=false,$is_gmt=false) { static $daylight; +global $ADODB_DATETIME_CLASS; if ($d === false) return ($is_gmt)? @gmdate($fmt): @date($fmt); if (!defined('ADODB_TEST_DATES')) { @@ -992,7 +1062,14 @@ */ for ($i=0; $i < $max; $i++) { switch($fmt[$i]) { - case 'T': $dates .= date('T');break; + case 'T': + if ($ADODB_DATETIME_CLASS) { + $dt = new DateTime(); + $dt->SetDate($year,$month,$day); + $dates .= $dt->Format('T'); + } else + $dates .= date('T'); + break; // YEAR case 'L': $dates .= $arr['leap'] ? '1' : '0'; break; case 'r': // Thu, 21 Dec 2000 16:01:07 +0200 @@ -1008,11 +1085,9 @@ if ($secs < 10) $dates .= ':0'.$secs; else $dates .= ':'.$secs; - $gmt = adodb_get_gmt_diff(); - if ($isphp5) - $dates .= sprintf(' %s%04d',($gmt<=0)?'+':'-',abs($gmt)/36); - else - $dates .= sprintf(' %s%04d',($gmt<0)?'+':'-',abs($gmt)/36); + $gmt = adodb_get_gmt_diff($year,$month,$day); + + $dates .= ' '.adodb_tz_offset($gmt,$isphp5); break; case 'Y': $dates .= $year; break; @@ -1041,14 +1116,11 @@ // HOUR case 'Z': - $dates .= ($is_gmt) ? 0 : -adodb_get_gmt_diff(); break; + $dates .= ($is_gmt) ? 0 : -adodb_get_gmt_diff($year,$month,$day); break; case 'O': - $gmt = ($is_gmt) ? 0 : adodb_get_gmt_diff(); + $gmt = ($is_gmt) ? 0 : adodb_get_gmt_diff($year,$month,$day); - if ($isphp5) - $dates .= sprintf('%s%04d',($gmt<=0)?'+':'-',abs($gmt)/36); - else - $dates .= sprintf('%s%04d',($gmt<0)?'+':'-',abs($gmt)/36); + $dates .= adodb_tz_offset($gmt,$isphp5); break; case 'H': @@ -1139,7 +1211,7 @@ } } - $gmt_different = ($is_gmt) ? 0 : adodb_get_gmt_diff(); + $gmt_different = ($is_gmt) ? 0 : adodb_get_gmt_diff($year,$mon,$day); /* # disabled because some people place large values in $sec. Modified: branches/vendor/gallery2/lib/adodb/adodb.inc.php =================================================================== --- branches/vendor/gallery2/lib/adodb/adodb.inc.php 2008-01-10 19:07:17 UTC (rev 17352) +++ branches/vendor/gallery2/lib/adodb/adodb.inc.php 2008-01-10 19:14:54 UTC (rev 17353) @@ -14,7 +14,7 @@ /** \mainpage - @version V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. + @version V4.96 24 Sept 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. Released under both BSD license and Lesser GPL library license. You can choose which license you prefer. @@ -176,7 +176,7 @@ /** * ADODB version as a string. */ - $ADODB_vers = 'V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. Released BSD & LGPL.'; + $ADODB_vers = 'V4.96 24 Sept 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. Released BSD & LGPL.'; /** * Determines whether recordset->RecordCount() is used. @@ -920,7 +920,9 @@ } if ($this->_queryID === true) { // return simplified recordset for inserts/updates/deletes with lower overhead - $rs = new ADORecordSet_empty(); + $rsclass = $this->rsPrefix.'empty'; + $rs = (class_exists($rsclass)) ? new $rsclass(): new ADORecordSet_empty(); + return $rs; } @@ -1303,7 +1305,9 @@ $ret = false; $rs = &$this->Execute($sql,$inputarr); if ($rs) { - if (!$rs->EOF) $ret = reset($rs->fields); + if ($rs->EOF) $ret = null; + else $ret = reset($rs->fields); + $rs->Close(); } $ADODB_COUNTRECS = $crecs; @@ -1315,7 +1319,8 @@ $ret = false; $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr); if ($rs) { - if (!$rs->EOF) $ret = reset($rs->fields); + if ($rs->EOF) $ret = null; + else $ret = reset($rs->fields); $rs->Close(); } @@ -1443,8 +1448,13 @@ return $arr; } + function GetRandRow($sql, $arr= false) + { + $rezarr = $this->GetAll($sql, $arr); + $sz = sizeof($rez); + return $rezarr[abs(rand()) % $sz]; + } - /** * Return one row of sql statement. Recordset is disposed for you. * Modified: branches/vendor/gallery2/lib/adodb/drivers/adodb-ado.inc.php =================================================================== --- branches/vendor/gallery2/lib/adodb/drivers/adodb-ado.inc.php 2008-01-10 19:07:17 UTC (rev 17352) +++ branches/vendor/gallery2/lib/adodb/drivers/adodb-ado.inc.php 2008-01-10 19:14:54 UTC (rev 17353) @@ -1,6 +1,6 @@ <?php /* -V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. +V4.96 24 Sept 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, the BSD license will take precedence. @@ -587,6 +587,17 @@ ADOConnection::outp( '<b>'.$f->Name.': currency type not supported by PHP</b>'); $this->fields[] = (float) $f->value; break; + case 11: //BIT; + $val = ""; + if(is_bool($f->value)) { + if($f->value==true) $val = 1; + else $val = 0; + } + if(is_null($f->value)) $val = null; + + $this->fields[] = $val; + break; + default: $this->fields[] = $f->value; break; Modified: branches/vendor/gallery2/lib/adodb/drivers/adodb-ado5.inc.php =================================================================== --- branches/vendor/gallery2/lib/adodb/drivers/adodb-ado5.inc.php 2008-01-10 19:07:17 UTC (rev 17352) +++ branches/vendor/gallery2/lib/adodb/drivers/adodb-ado5.inc.php 2008-01-10 19:14:54 UTC (rev 17353) @@ -1,6 +1,6 @@ <?php /* -V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. +V4.96 24 Sept 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, the BSD license will take precedence. @@ -618,6 +618,16 @@ ADOConnection::outp( '<b>'.$f->Name.': currency type not supported by PHP</b>'); $this->fields[] = (float) $f->value; break; + case 11: //BIT; + $val = ""; + if(is_bool($f->value)) { + if($f->value==true) $val = 1; + else $val = 0; + } + if(is_null($f->value)) $val = null; + + $this->fields[] = $val; + break; default: $this->fields[] = $f->value; break; Modified: branches/vendor/gallery2/lib/adodb/drivers/adodb-ado_mssql.inc.php =================================================================== --- branches/vendor/gallery2/lib/adodb/drivers/adodb-ado_mssql.inc.php 2008-01-10 19:07:17 UTC (rev 17352) +++ branches/vendor/gallery2/lib/adodb/drivers/adodb-ado_mssql.inc.php 2008-01-10 19:14:54 UTC (rev 17353) @@ -1,6 +1,6 @@ <?php /* -V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. +V4.96 24 Sept 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, the BSD license will take precedence. @@ -46,7 +46,7 @@ function _insertid() { - return $this->GetOne('select @@identity'); + return $this->GetOne('select SCOPE_IDENTITY()'); } function _affectedrows() Modified: branches/vendor/gallery2/lib/adodb/drivers/adodb-db2.inc.php =================================================================== --- branches/vendor/gallery2/lib/adodb/drivers/adodb-db2.inc.php 2008-01-10 19:07:17 UTC (rev 17352) +++ branches/vendor/gallery2/lib/adodb/drivers/adodb-db2.inc.php 2008-01-10 19:14:54 UTC (rev 17353) @@ -1,6 +1,6 @@ <?php /* - V4.94 23 Jan 2007 (c) 2006 John Lim (jlim#natsoft.com.my). All rights reserved. + V4.96 24 Sept 2007 (c) 2006 John Lim (jlim#natsoft.com.my). All rights reserved. This is a version of the ADODB driver for DB2. It uses the 'ibm_db2' PECL extension for PHP (http://pecl.php.net/package/ibm_db2), which in turn requires DB2 V8.2.2 or Modified: branches/vendor/gallery2/lib/adodb/drivers/adodb-mysql.inc.php =================================================================== --- branches/vendor/gallery2/lib/adodb/drivers/adodb-mysql.inc.php 2008-01-10 19:07:17 UTC (rev 17352) +++ branches/vendor/gallery2/lib/adodb/drivers/adodb-mysql.inc.php 2008-01-10 19:14:54 UTC (rev 17353) @@ -1,6 +1,6 @@ <?php /* -V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. +V4.96 24 Sept 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, the BSD license will take precedence. @@ -132,6 +132,8 @@ // if magic quotes disabled, use mysql_real_escape_string() function qstr($s,$magic_quotes=false) { + if (is_null($s)) return 'NULL'; + if (!$magic_quotes) { if (ADODB_PHPVER >= 0x4300) { Modified: branches/vendor/gallery2/lib/adodb/drivers/adodb-mysqli.inc.php =================================================================== --- branches/vendor/gallery2/lib/adodb/drivers/adodb-mysqli.inc.php 2008-01-10 19:07:17 UTC (rev 17352) +++ branches/vendor/gallery2/lib/adodb/drivers/adodb-mysqli.inc.php 2008-01-10 19:14:54 UTC (rev 17353) @@ -1,6 +1,6 @@ <?php /* -V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. +V4.96 24 Sept 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, the BSD license will take precedence. @@ -50,6 +50,7 @@ var $_bindInputArray = false; var $nameQuote = '`'; /// string to use to quote identifiers and names var $optionFlags = array(array(MYSQLI_READ_DEFAULT_GROUP,0)); + var $arrayClass = 'ADORecordSet_array_mysqli'; function ADODB_mysqli() { @@ -212,6 +213,7 @@ //Eg. $s = $db->qstr(_GET['name'],get_magic_quotes_gpc()); function qstr($s, $magic_quotes = false) { + if (is_null($s)) return 'NULL'; if (!$magic_quotes) { if (PHP_VERSION >= 5) return "'" . mysqli_real_escape_string($this->_connectionID, $s) . "'"; @@ -1022,4 +1024,108 @@ } +class ADORecordSet_array_mysqli extends ADORecordSet_array { + function ADORecordSet_array_mysqli($id=-1,$mode=false) + { + $this->ADORecordSet_array($id,$mode); + } + + + function MetaType($t, $len = -1, $fieldobj = false) + { + if (is_object($t)) { + $fieldobj = $t; + $t = $fieldobj->type; + $len = $fieldobj->max_length; + } + + + $len = -1; // mysql max_length is not accurate + switch (strtoupper($t)) { + case 'STRING': + case 'CHAR': + case 'VARCHAR': + case 'TINYBLOB': + case 'TINYTEXT': + case 'ENUM': + case 'SET': + + case MYSQLI_TYPE_TINY_BLOB : + case MYSQLI_TYPE_CHAR : + case MYSQLI_TYPE_STRING : + case MYSQLI_TYPE_ENUM : + case MYSQLI_TYPE_SET : + case 253 : + if ($len <= $this->blobSize) return 'C'; + + case 'TEXT': + case 'LONGTEXT': + case 'MEDIUMTEXT': + return 'X'; + + + // php_mysql extension always returns 'blob' even if 'text' + // so we have to check whether binary... + case 'IMAGE': + case 'LONGBLOB': + case 'BLOB': + case 'MEDIUMBLOB': + + case MYSQLI_TYPE_BLOB : + case MYSQLI_TYPE_LONG_BLOB : + case MYSQLI_TYPE_MEDIUM_BLOB : + + return !empty($fieldobj->binary) ? 'B' : 'X'; + case 'YEAR': + case 'DATE': + case MYSQLI_TYPE_DATE : + case MYSQLI_TYPE_YEAR : + + return 'D'; + + case 'TIME': + case 'DATETIME': + case 'TIMESTAMP': + + case MYSQLI_TYPE_DATETIME : + case MYSQLI_TYPE_NEWDATE : + case MYSQLI_TYPE_TIME : + case MYSQLI_TYPE_TIMESTAMP : + + return 'T'; + + case 'INT': + case 'INTEGER': + case 'BIGINT': + case 'TINYINT': + case 'MEDIUMINT': + case 'SMALLINT': + + case MYSQLI_TYPE_INT24 : + case MYSQLI_TYPE_LONG : + case MYSQLI_TYPE_LONGLONG : + case MYSQLI_TYPE_SHORT : + case MYSQLI_TYPE_TINY : + + if (!empty($fieldobj->primary_key)) return 'R'; + + return 'I'; + + + // Added floating-point types + // Maybe not necessery. + case 'FLOAT': + case 'DOUBLE': + // case 'DOUBLE PRECISION': + case 'DECIMAL': + case 'DEC': + case 'FIXED': + default: + //if (!is_numeric($t)) echo "<p>--- Error in type matching $t -----</p>"; + return 'N'; + } + } // function + +} + ?> \ No newline at end of file Modified: branches/vendor/gallery2/lib/adodb/drivers/adodb-mysqlt.inc.php =================================================================== --- branches/vendor/gallery2/lib/adodb/drivers/adodb-mysqlt.inc.php 2008-01-10 19:07:17 UTC (rev 17352) +++ branches/vendor/gallery2/lib/adodb/drivers/adodb-mysqlt.inc.php 2008-01-10 19:14:54 UTC (rev 17353) @@ -1,7 +1,7 @@ <?php /* -V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. +V4.96 24 Sept 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, the BSD license will take precedence. Modified: branches/vendor/gallery2/lib/adodb/drivers/adodb-oci8.inc.php =================================================================== --- branches/vendor/gallery2/lib/adodb/drivers/adodb-oci8.inc.php 2008-01-10 19:07:17 UTC (rev 17352) +++ branches/vendor/gallery2/lib/adodb/drivers/adodb-oci8.inc.php 2008-01-10 19:14:54 UTC (rev 17353) @@ -1,7 +1,7 @@ <?php /* - version V4.94 23 Jan 2007 (c) 2000-2007 John Lim. All rights reserved. + version V4.96 24 Sept 2007 (c) 2000-2007 John Lim. All rights reserved. Released under both BSD license and Lesser GPL library license. Whenever there is any discrepancy between the two licenses, @@ -541,6 +541,12 @@ return $s. "')"; } + function GetRandRow($sql, $arr = false) + { + $sql = "SELECT * FROM ($sql ORDER BY dbms_random.value) WHERE rownum = 1"; + + return $this->GetRow($sql,$arr); + } /* This algorithm makes use of @@ -567,7 +573,7 @@ $sql = preg_replace('/^[ \t\n]*select/i','SELECT /*+FIRST_ROWS*/',$sql); } - if ($offset < $this->selectOffsetAlg1) { + if ($offset < $this->selectOffsetAlg1 && 0 < $nrows && $nrows < 1000) { if ($nrows > 0) { if ($offset > 0) $nrows += $offset; //$inputarr['adodb_rownum'] = $nrows; @@ -748,7 +754,6 @@ } if ($inputarr) { #if (!is_array($inputarr)) $inputarr = array($inputarr); - $element0 = reset($inputarr); # is_object check because oci8 descriptors can be passed in Modified: branches/vendor/gallery2/lib/adodb/drivers/adodb-oci805.inc.php =================================================================== --- branches/vendor/gallery2/lib/adodb/drivers/adodb-oci805.inc.php 2008-01-10 19:07:17 UTC (rev 17352) +++ branches/vendor/gallery2/lib/adodb/drivers/adodb-oci805.inc.php 2008-01-10 19:14:54 UTC (rev 17353) @@ -1,6 +1,6 @@ <?php /** - * @version V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. + * @version V4.96 24 Sept 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, * the BSD license will take precedence. Modified: branches/vendor/gallery2/lib/adodb/drivers/adodb-oci8po.inc.php =================================================================== --- branches/vendor/gallery2/lib/adodb/drivers/adodb-oci8po.inc.php 2008-01-10 19:07:17 UTC (rev 17352) +++ branches/vendor/gallery2/lib/adodb/drivers/adodb-oci8po.inc.php 2008-01-10 19:14:54 UTC (rev 17353) @@ -1,6 +1,6 @@ <?php /* -V4.94 23 Jan 2007 (c) 2000-2007 John Lim. All rights reserved. +V4.96 24 Sept 2007 (c) 2000-2007 John Lim. 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. Modified: branches/vendor/gallery2/lib/adodb/drivers/adodb-oracle.inc.php =================================================================== --- branches/vendor/gallery2/lib/adodb/drivers/adodb-oracle.inc.php 2008-01-10 19:07:17 UTC (rev 17352) +++ branches/vendor/gallery2/lib/adodb/drivers/adodb-oracle.inc.php 2008-01-10 19:14:54 UTC (rev 17353) @@ -1,6 +1,6 @@ <?php /* -V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. +V4.96 24 Sept 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, the BSD license will take precedence. Modified: branches/vendor/gallery2/lib/adodb/drivers/adodb-postgres64.inc.php =================================================================== --- branches/vendor/gallery2/lib/adodb/drivers/adodb-postgres64.inc.php 2008-01-10 19:07:17 UTC (rev 17352) +++ branches/vendor/gallery2/lib/adodb/drivers/adodb-postgres64.inc.php 2008-01-10 19:14:54 UTC (rev 17353) @@ -1,6 +1,6 @@ <?php /* - V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. + V4.96 24 Sept 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, the BSD license will take precedence. Modified: branches/vendor/gallery2/lib/adodb/drivers/adodb-postgres7.inc.php =================================================================== --- branches/vendor/gallery2/lib/adodb/drivers/adodb-postgres7.inc.php 2008-01-10 19:07:17 UTC (rev 17352) +++ branches/vendor/gallery2/lib/adodb/drivers/adodb-postgres7.inc.php 2008-01-10 19:14:54 UTC (rev 17353) @@ -1,6 +1,6 @@ <?php /* - V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. + V4.96 24 Sept 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, the BSD license will take precedence. Modified: branches/vendor/gallery2/lib/adodb/perf/perf-db2.inc.php =================================================================== --- branches/vendor/gallery2/lib/adodb/perf/perf-db2.inc.php 2008-01-10 19:07:17 UTC (rev 17352) +++ branches/vendor/gallery2/lib/adodb/perf/perf-db2.inc.php 2008-01-10 19:14:54 UTC (rev 17353) @@ -1,6 +1,6 @@ <?php /* -V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. +V4.96 24 Sept 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, the BSD license will take precedence. See License.txt. Modified: branches/vendor/gallery2/lib/adodb/perf/perf-mssql.inc.php =================================================================== --- branches/vendor/gallery2/lib/adodb/perf/perf-mssql.inc.php 2008-01-10 19:07:17 UTC (rev 17352) +++ branches/vendor/gallery2/lib/adodb/perf/perf-mssql.inc.php 2008-01-10 19:14:54 UTC (rev 17353) @@ -1,7 +1,7 @@ <?php /* -V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. +V4.96 24 Sept 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, the BSD license will take precedence. See License.txt. Modified: branches/vendor/gallery2/lib/adodb/perf/perf-mysql.inc.php =================================================================== --- branches/vendor/gallery2/lib/adodb/perf/perf-mysql.inc.php 2008-01-10 19:07:17 UTC (rev 17352) +++ branches/vendor/gallery2/lib/adodb/perf/perf-mysql.inc.php 2008-01-10 19:14:54 UTC (rev 17353) @@ -1,6 +1,6 @@ <?php /* -V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. +V4.96 24 Sept 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, the BSD license will take precedence. See License.txt. Modified: branches/vendor/gallery2/lib/adodb/perf/perf-oci8.inc.php =================================================================== --- branches/vendor/gallery2/lib/adodb/perf/perf-oci8.inc.php 2008-01-10 19:07:17 UTC (rev 17352) +++ branches/vendor/gallery2/lib/adodb/perf/perf-oci8.inc.php 2008-01-10 19:14:54 UTC (rev 17353) @@ -1,6 +1,6 @@ <?php /* -V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. +V4.96 24 Sept 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, the BSD license will take precedence. See License.txt. @@ -156,7 +156,25 @@ 'random page cost' => array('COST', "select value from v\$parameter where name = 'optimizer_index_cost_adj'", '=WarnPageCost'), - + + 'Backup', + 'Achivelog Mode' => array('BACKUP', 'select log_mode from v$database', 'To turn on archivelog:<br> + <pre> + SQLPLUS> connect sys as sysdba; + SQLPLUS> shutdown immediate; + + SQLPLUS> startup mount exclusive; + SQLPLUS> alter database archivelog; + SQLPLUS> archive log start; + SQLPLUS> alter database open; +</pre>'), + + 'DBID' => array('BACKUP','select dbid from v$database','Primary key of database, used for recovery with an RMAN Recovery Catalog'), + 'Archive Log Dest' => array('BACKUP', "SELECT NVL(v1.value,v2.value) +FROM v\$parameter v1, v\$parameter v2 WHERE v1.name='log_archive_dest' AND v2.name='log_archive_dest_10'", ''), + + 'Flashback Area' => array('BACKUP', "select nvl(value,'Flashback Area not used') from v\$parameter where name=lower('DB_RECOVERY_FILE_DEST')", 'Flashback area is a folder where all backup data and logs can be stored and managed by Oracle. If Error: message displayed, then it is not in use.'), + 'Control File Keep Time' => array('BACKUP', "select value from v\$parameter where name='control_file_record_keep_time'",'No of days to keep RMAN info in control file. I recommend it be set to x2 or x3 times the frequency of your full backup.'), false ); @@ -184,7 +202,7 @@ else $s = ''; return $s.'Percentage of indexed data blocks expected in the cache. - Recommended is 20 (fast disk array) to 50 (slower hard disks). Default is 0. + Recommended is 20 (fast disk array) to 30 (slower hard disks). Default is 0. See <a href=http://www.dba-oracle.com/oracle_tips_cbo_part1.htm>optimizer_index_caching</a>.'; } @@ -250,7 +268,7 @@ if ($partial) { $sqlq = $this->conn->qstr($sql.'%'); - $arr = $this->conn->GetArray("select distinct distinct sql1 from adodb_logsql where sql1 like $sqlq"); + $arr = $this->conn->GetArray("select distinct sql1 from adodb_logsql where sql1 like $sqlq"); if ($arr) { foreach($arr as $row) { $sql = reset($row); @@ -505,5 +523,28 @@ return $s; } + function clearsql() + { + $this->conn->debug=1; + $perf_table = adodb_perf::table(); + // using the naive "delete from $perf_table where created<".$this->conn->sysTimeStamp will cause the table to lock, possibly + // for a long time + $sql = +"DECLARE cnt pls_integer; +BEGIN + cnt := 0; + FOR rec IN (SELECT ROWID AS rr FROM $perf_table WHERE created<SYSDATE) + LOOP + cnt := cnt + 1; + DELETE FROM $perf_table WHERE ROWID=rec.rr; + IF cnt = 10000 THEN + COMMIT; + cnt := 0; + END IF; + END LOOP; +END;"; + + $ok = $this->conn->Execute($sql); + } } ?> \ No newline at end of file Modified: branches/vendor/gallery2/lib/adodb/perf/perf-postgres.inc.php =================================================================== --- branches/vendor/gallery2/lib/adodb/perf/perf-postgres.inc.php 2008-01-10 19:07:17 UTC (rev 17352) +++ branches/vendor/gallery2/lib/adodb/perf/perf-postgres.inc.php 2008-01-10 19:14:54 UTC (rev 17353) @@ -1,7 +1,7 @@ <?php /* -V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. +V4.96 24 Sept 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, the BSD license will take precedence. See License.txt. @@ -92,6 +92,37 @@ $this->conn =& $conn; } + var $optimizeTableLow = 'VACUUM %s'; + var $optimizeTableHigh = 'VACUUM ANALYZE %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 : + { + ADOConnection::outp(sprintf("<p>%s: '%s' using of undefined mode '%s'</p>", __CLASS__, 'optimizeTable', $mode)); + return false; + } + } + $sql = sprintf($sql, $table); + + return $conn->Execute($sql) !== false; + } + + + function Explain($sql,$partial=false) { $save = $this->conn->LogSQL(false); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |