<?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.
Latest version is available at http://adodb.sourceforge.net
Released under both BSD license and Lesser GPL library license.
Active Record implementation. Superset of Zend Framework's.
- Version 0.07
+ Version 0.08
See http://www-128.ibm.com/developerworks/java/library/j-cb03076/?ca=dgr-lnxw01ActiveRecord
for info on Ruby on Rails Active Record implementation
return false;
}
+ $keys = array_keys($row);
$cnt = 0;
foreach($table->flds as $name=>$fld) {
- $this->$name = $row[$cnt];
+ $this->$name = $row[$keys[$cnt]];
$cnt += 1;
}
$this->_original = $row;
/*
- 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.
<?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.
<?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.
<?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.
<?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.
<?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.
<?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.
<?php
-
+
// security - hide paths
if (!defined('ADODB_DIR')) die();
$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.
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
$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;
}
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.")";
$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
// 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];
break;
case "L": //Integer field suitable for storing booleans (0 or 1)
-// moodle change end
case "I":
case "R":
$val = (int) $arrFields[$fname];
break;
+// moodle change end
default:
$val = str_replace(array("'"," ","("),"",$arrFields[$fname]); // basic sql injection defence
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 ]";
}
}
*/
-?>
+?>
\ No newline at end of file
<?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.
<?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.
<?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.
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;
$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);
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%
<?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.
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.
/*
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
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;
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;
}
// 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");
// 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);
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;
}
{
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;
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;
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)
{
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')) {
*/
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
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;
// 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':
}
}
- $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.
/**
\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.
/**
* 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.
}
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;
}
$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;
$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();
}
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.
<?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.
<?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.
<?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.
<?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.
<?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.
<?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.
<?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.
<?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.
<?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.
<?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.
* @param array/ $tableoptions options for the new table see CreateTableSQL, default ''
* @return array with SQL strings
*/
- function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
+ /*function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
{
if (!$tableflds) {
if ($this->debug) ADOConnection::outp("AlterColumnSQL needs a complete table-definiton for PostgreSQL");
return array();
}
return $this->_recreate_copy_table($tabname,False,$tableflds,$tableoptions);
+ }*/
+
+ function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
+ {
+ // Check if alter single column datatype available - works with 8.0+
+ $has_alter_column = 8.0 <= (float) @$this->serverInfo['version'];
+
+ if ($has_alter_column) {
+ $tabname = $this->TableName($tabname);
+ $sql = array();
+ list($lines,$pkey) = $this->_GenFields($flds);
+ $alter = 'ALTER TABLE ' . $tabname . $this->alterCol . ' ';
+ foreach($lines as $v) {
+ if ($not_null = preg_match('/NOT NULL/i',$v)) {
+ $v = preg_replace('/NOT NULL/i','',$v);
+ }
+ // this next block doesn't work - there is no way that I can see to
+ // explicitly ask a column to be null using $flds
+ else if ($set_null = preg_match('/NULL/i',$v)) {
+ // if they didn't specify not null, see if they explicitely asked for null
+ $v = preg_replace('/\sNULL/i','',$v);
+ }
+
+ if (preg_match('/^([^ ]+) .*DEFAULT ([^ ]+)/',$v,$matches)) {
+ list(,$colname,$default) = $matches;
+ $v = preg_replace('/^' . preg_quote($colname) . '\s/', '', $v);
+ $sql[] = $alter . $colname . ' TYPE ' . str_replace('DEFAULT '.$default,'',$v);
+ $sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' SET DEFAULT ' . $default;
+ }
+ else {
+ // drop default?
+ preg_match ('/^\s*(\S+)\s+(.*)$/',$v,$matches);
+ list (,$colname,$rest) = $matches;
+ $sql[] = $alter . $colname . ' TYPE ' . $rest;
+ }
+
+ list($colname) = explode(' ',$v);
+ if ($not_null) {
+ // this does not error out if the column is already not null
+ $sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' SET NOT NULL';
+ }
+ if ($set_null) {
+ // this does not error out if the column is already null
+ $sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' DROP NOT NULL';
+ }
+ }
+ return $sql;
+ }
+
+ // does not have alter column
+ if (!$tableflds) {
+ if ($this->debug) ADOConnection::outp("AlterColumnSQL needs a complete table-definiton for PostgreSQL");
+ return array();
+ }
+ return $this->_recreate_copy_table($tabname,False,$tableflds,$tableoptions);
}
/**
return "DROP SEQUENCE ".$seq;
}
+ function RenameTableSQL($tabname,$newname)
+ {
+ if (!empty($this->schema)) {
+ $rename_from = $this->TableName($tabname);
+ $schema_save = $this->schema;
+ $this->schema = false;
+ $rename_to = $this->TableName($newname);
+ $this->schema = $schema_save;
+ return array (sprintf($this->renameTable, $rename_from, $rename_to));
+ }
+
+ return array (sprintf($this->renameTable, $this->TableName($tabname),$this->TableName($newname)));
+ }
+
/*
CREATE [ [ LOCAL ] { TEMPORARY | TEMP } ] TABLE table_name (
{ column_name data_type [ DEFAULT default_expr ] [ column_constraint [, ... ] ]
<?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.
<?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.
<?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.
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;
<?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.
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;
<?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.
<?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.
function _insertid()
{
- return $this->GetOne('select @@identity');
+ return $this->GetOne('select SCOPE_IDENTITY()');
}
function _affectedrows()
<?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.
<?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.
<?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
<?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.
<?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.
<?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.
<?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.
<?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.
<?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.
# Options configuration information
var $LDAP_CONNECT_OPTIONS;
+
+ # error on binding, eg. "Binding: invalid credentials"
+ var $_bind_errmsg = "Binding: %s";
function ADODB_ldap()
{
}
// returns true or false
-
function _connect( $host, $username, $password, $ldapbase)
{
global $LDAP_CONNECT_OPTIONS;
$conn_info = split( ':', $host );
}
- $this->_connectionID = ldap_connect( $conn_info[0], $conn_info[1] );
+ $this->_connectionID = @ldap_connect( $conn_info[0], $conn_info[1] );
if (!$this->_connectionID) {
$e = 'Could not connect to ' . $conn_info[0];
$this->_errorMsg = $e;
}
if ($username) {
- $bind = ldap_bind( $this->_connectionID, $username, $password );
+ $bind = @ldap_bind( $this->_connectionID, $username, $password );
} else {
$username = 'anonymous';
- $bind = ldap_bind( $this->_connectionID );
+ $bind = @ldap_bind( $this->_connectionID );
}
if (!$bind) {
- $e = 'Could not bind to ' . $conn_info[0] . " as ".$username;
+ $e = sprintf($this->_bind_errmsg,ldap_error($this->_connectionID));;
$this->_errorMsg = $e;
if ($this->debug) ADOConnection::outp($e);
return false;
/* returns _queryID or false */
function _query($sql,$inputarr)
{
- $rs = ldap_search( $this->_connectionID, $this->database, $sql );
- $this->_errorMsg = ($rs) ? '' : 'Search error on '.$sql;
+ $rs = @ldap_search( $this->_connectionID, $this->database, $sql );
+ $this->_errorMsg = ($rs) ? '' : 'Search error on '.$sql.': '. ldap_error($this->_connectionID);
return $rs;
}
+
+ function ErrorMsg()
+ {
+ return $this->_errorMsg;
+ }
+
+ function ErrorNo()
+ {
+ return @ldap_errno($this->_connectionID);
+ }
/* closes the LDAP connection */
function _close()
<?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.
// http://support.microsoft.com/default.aspx?scid=kb;EN-US;q220918
// Alternatively use:
// CONVERT(char(12),datecol,120)
+//
+// Also if your month is showing as month-1,
+// e.g. Jan 13, 2002 is showing as 13/0/2002, then see
+// http://phplens.com/lens/lensforum/msgs.php?id=7048&x=1
+// it's a localisation problem.
//----------------------------------------------------------------
var $rightOuter = '=*';
var $ansiOuter = true; // for mssql7 or later
var $poorAffectedRows = true;
- var $identitySQL = 'select @@IDENTITY'; // 'select SCOPE_IDENTITY'; # for mssql 2000
+ var $identitySQL = 'select SCOPE_IDENTITY()'; // 'select SCOPE_IDENTITY'; # for mssql 2000
var $uniqueOrderBy = true;
var $_bindInputArray = true;
-<?php\r
-\r
-/// $Id $\r
-\r
-///////////////////////////////////////////////////////////////////////////\r
-// //\r
-// NOTICE OF COPYRIGHT //\r
-// //\r
-// ADOdb - Database Abstraction Library for PHP //\r
-// http://adodb.sourceforge.net/ //\r
-// //\r
-// Copyright (C) 2000-2007 John Lim (jlim\@natsoft.com.my) //\r
-// All rights reserved. //\r
-// Released under both BSD license and LGPL library license. //\r
-// Whenever there is any discrepancy between the two licenses, //\r
-// the BSD license will take precedence //\r
-// //\r
-// Moodle - Modular Object-Oriented Dynamic Learning Environment //\r
-// http://moodle.com //\r
-// //\r
-// Copyright (C) 2001-3001 Martin Dougiamas http://dougiamas.com //\r
-// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //\r
-// //\r
-// This program is free software; you can redistribute it and/or modify //\r
-// it under the terms of the GNU General Public License as published by //\r
-// the Free Software Foundation; either version 2 of the License, or //\r
-// (at your option) any later version. //\r
-// //\r
-// This program is distributed in the hope that it will be useful, //\r
-// but WITHOUT ANY WARRANTY; without even the implied warranty of //\r
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //\r
-// GNU General Public License for more details: //\r
-// //\r
-// http://www.gnu.org/copyleft/gpl.html //\r
-// //\r
-///////////////////////////////////////////////////////////////////////////\r
-\r
-/**\r
-* MSSQL Driver with auto-prepended "N" for correct unicode storage\r
-* of SQL literal strings. Intended to be used with MSSQL drivers that\r
-* are sending UCS-2 data to MSSQL (FreeTDS and ODBTP) in order to get\r
-* true cross-db compatibility from the application point of view.\r
-*/\r
-\r
-// security - hide paths\r
-if (!defined('ADODB_DIR')) die();\r
-\r
-// one useful constant\r
-if (!defined('SINGLEQUOTE')) define('SINGLEQUOTE', "'");\r
-\r
-include_once(ADODB_DIR.'/drivers/adodb-mssql.inc.php');\r
-\r
-class ADODB_mssql_n extends ADODB_mssql {\r
- var $databaseType = "mssql_n";\r
- \r
- function ADODB_mssqlpo()\r
- {\r
- ADODB_mssql::ADODB_mssql();\r
- }\r
-\r
- function _query($sql,$inputarr)\r
- {\r
- $sql = $this->_appendN($sql);\r
- return ADODB_mssql::_query($sql,$inputarr);\r
- }\r
-\r
- /**\r
- * This function will intercept all the literals used in the SQL, prepending the "N" char to them\r
- * in order to allow mssql to store properly data sent in the correct UCS-2 encoding (by freeTDS\r
- * and ODBTP) keeping SQL compatibility at ADOdb level (instead of hacking every project to add\r
- * the "N" notation when working against MSSQL.\r
- *\r
- * Note that this hack only must be used if ALL the char-based columns in your DB are of type nchar,\r
- * nvarchar and ntext\r
- */\r
- function _appendN($sql) {\r
-\r
- $result = $sql;\r
-\r
- /// Check we have some single quote in the query. Exit ok.\r
- if (strpos($sql, SINGLEQUOTE) === false) {\r
- return $sql;\r
- }\r
-\r
- /// Check we haven't an odd number of single quotes (this can cause problems below\r
- /// and should be considered one wrong SQL). Exit with debug info.\r
- if ((substr_count($sql, SINGLEQUOTE) & 1)) {\r
- if ($this->debug) {\r
- ADOConnection::outp("{$this->databaseType} internal transformation: not converted. Wrong number of quotes (odd)");\r
- }\r
- return $sql;\r
- }\r
-\r
- /// Check we haven't any backslash + single quote combination. It should mean wrong\r
- /// backslashes use (bad magic_quotes_sybase?). Exit with debug info.\r
- $regexp = '/(\\\\' . SINGLEQUOTE . '[^' . SINGLEQUOTE . '])/';\r
- if (preg_match($regexp, $sql)) {\r
- if ($this->debug) {\r
- ADOConnection::outp("{$this->databaseType} internal transformation: not converted. Found bad use of backslash + single quote");\r
- }\r
- return $sql;\r
- }\r
-\r
- /// Remove pairs of single-quotes\r
- $pairs = array();\r
- $regexp = '/(' . SINGLEQUOTE . SINGLEQUOTE . ')/';\r
- preg_match_all($regexp, $result, $list_of_pairs);\r
- if ($list_of_pairs) {\r
- foreach (array_unique($list_of_pairs[0]) as $key=>$value) {\r
- $pairs['<@#@#@PAIR-'.$key.'@#@#@>'] = $value;\r
- }\r
- if (!empty($pairs)) {\r
- $result = str_replace($pairs, array_keys($pairs), $result);\r
- }\r
- }\r
-\r
- /// Remove the rest of literals present in the query\r
- $literals = array();\r
- $regexp = '/(N?' . SINGLEQUOTE . '.*?' . SINGLEQUOTE . ')/is';\r
- preg_match_all($regexp, $result, $list_of_literals);\r
- if ($list_of_literals) {\r
- foreach (array_unique($list_of_literals[0]) as $key=>$value) {\r
- $literals['<#@#@#LITERAL-'.$key.'#@#@#>'] = $value;\r
- }\r
- if (!empty($literals)) {\r
- $result = str_replace($literals, array_keys($literals), $result);\r
- }\r
- }\r
-\r
-\r
- /// Analyse literals to prepend the N char to them if their contents aren't numeric\r
- if (!empty($literals)) {\r
- foreach ($literals as $key=>$value) {\r
- if (!is_numeric(trim($value, SINGLEQUOTE))) {\r
- /// Non numeric string, prepend our dear N\r
- $literals[$key] = 'N' . trim($value, 'N'); //Trimming potentially existing previous "N"\r
- }\r
- }\r
- }\r
-\r
- /// Re-apply literals to the text\r
- if (!empty($literals)) {\r
- $result = str_replace(array_keys($literals), $literals, $result);\r
- }\r
-\r
- /// Any pairs followed by N' must be switched to N' followed by those pairs\r
- /// (or strings beginning with single quotes will fail)\r
- $result = preg_replace("/((<@#@#@PAIR-(\d+)@#@#@>)+)N'/", "N'$1", $result);\r
-\r
- /// Re-apply pairs of single-quotes to the text\r
- if (!empty($pairs)) {\r
- $result = str_replace(array_keys($pairs), $pairs, $result);\r
- }\r
-\r
- /// Print transformation if debug = on\r
- if ($result != $sql && $this->debug) {\r
- ADOConnection::outp("{$this->databaseType} internal transformation:<br>{$sql}<br>to<br>{$result}");\r
- }\r
-\r
- return $result;\r
- }\r
-}\r
-\r
-class ADORecordset_mssql_n extends ADORecordset_mssql {\r
- var $databaseType = "mssql_n";\r
- function ADORecordset_mssql_n($id,$mode=false)\r
- {\r
- $this->ADORecordset_mssql($id,$mode);\r
- }\r
-}\r
-?>\r
+<?php
+
+/// $Id $
+
+///////////////////////////////////////////////////////////////////////////
+// //
+// NOTICE OF COPYRIGHT //
+// //
+// ADOdb - Database Abstraction Library for PHP //
+// http://adodb.sourceforge.net/ //
+// //
+// Copyright (C) 2000-2007 John Lim (jlim\@natsoft.com.my) //
+// All rights reserved. //
+// Released under both BSD license and LGPL library license. //
+// Whenever there is any discrepancy between the two licenses, //
+// the BSD license will take precedence //
+// //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment //
+// http://moodle.com //
+// //
+// Copyright (C) 2001-3001 Martin Dougiamas http://dougiamas.com //
+// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
+// //
+// This program is free software; you can redistribute it and/or modify //
+// it under the terms of the GNU General Public License as published by //
+// the Free Software Foundation; either version 2 of the License, or //
+// (at your option) any later version. //
+// //
+// This program is distributed in the hope that it will be useful, //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
+// GNU General Public License for more details: //
+// //
+// http://www.gnu.org/copyleft/gpl.html //
+// //
+///////////////////////////////////////////////////////////////////////////
+
+/**
+* MSSQL Driver with auto-prepended "N" for correct unicode storage
+* of SQL literal strings. Intended to be used with MSSQL drivers that
+* are sending UCS-2 data to MSSQL (FreeTDS and ODBTP) in order to get
+* true cross-db compatibility from the application point of view.
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+// one useful constant
+if (!defined('SINGLEQUOTE')) define('SINGLEQUOTE', "'");
+
+include_once(ADODB_DIR.'/drivers/adodb-mssql.inc.php');
+
+class ADODB_mssql_n extends ADODB_mssql {
+ var $databaseType = "mssql_n";
+
+ function ADODB_mssqlpo()
+ {
+ ADODB_mssql::ADODB_mssql();
+ }
+
+ function _query($sql,$inputarr)
+ {
+ $sql = $this->_appendN($sql);
+ return ADODB_mssql::_query($sql,$inputarr);
+ }
+
+ /**
+ * This function will intercept all the literals used in the SQL, prepending the "N" char to them
+ * in order to allow mssql to store properly data sent in the correct UCS-2 encoding (by freeTDS
+ * and ODBTP) keeping SQL compatibility at ADOdb level (instead of hacking every project to add
+ * the "N" notation when working against MSSQL.
+ *
+ * Note that this hack only must be used if ALL the char-based columns in your DB are of type nchar,
+ * nvarchar and ntext
+ */
+ function _appendN($sql) {
+
+ $result = $sql;
+
+ /// Check we have some single quote in the query. Exit ok.
+ if (strpos($sql, SINGLEQUOTE) === false) {
+ return $sql;
+ }
+
+ /// Check we haven't an odd number of single quotes (this can cause problems below
+ /// and should be considered one wrong SQL). Exit with debug info.
+ if ((substr_count($sql, SINGLEQUOTE) & 1)) {
+ if ($this->debug) {
+ ADOConnection::outp("{$this->databaseType} internal transformation: not converted. Wrong number of quotes (odd)");
+ }
+ return $sql;
+ }
+
+ /// Check we haven't any backslash + single quote combination. It should mean wrong
+ /// backslashes use (bad magic_quotes_sybase?). Exit with debug info.
+ $regexp = '/(\\\\' . SINGLEQUOTE . '[^' . SINGLEQUOTE . '])/';
+ if (preg_match($regexp, $sql)) {
+ if ($this->debug) {
+ ADOConnection::outp("{$this->databaseType} internal transformation: not converted. Found bad use of backslash + single quote");
+ }
+ return $sql;
+ }
+
+ /// Remove pairs of single-quotes
+ $pairs = array();
+ $regexp = '/(' . SINGLEQUOTE . SINGLEQUOTE . ')/';
+ preg_match_all($regexp, $result, $list_of_pairs);
+ if ($list_of_pairs) {
+ foreach (array_unique($list_of_pairs[0]) as $key=>$value) {
+ $pairs['<@#@#@PAIR-'.$key.'@#@#@>'] = $value;
+ }
+ if (!empty($pairs)) {
+ $result = str_replace($pairs, array_keys($pairs), $result);
+ }
+ }
+
+ /// Remove the rest of literals present in the query
+ $literals = array();
+ $regexp = '/(N?' . SINGLEQUOTE . '.*?' . SINGLEQUOTE . ')/is';
+ preg_match_all($regexp, $result, $list_of_literals);
+ if ($list_of_literals) {
+ foreach (array_unique($list_of_literals[0]) as $key=>$value) {
+ $literals['<#@#@#LITERAL-'.$key.'#@#@#>'] = $value;
+ }
+ if (!empty($literals)) {
+ $result = str_replace($literals, array_keys($literals), $result);
+ }
+ }
+
+
+ /// Analyse literals to prepend the N char to them if their contents aren't numeric
+ if (!empty($literals)) {
+ foreach ($literals as $key=>$value) {
+ if (!is_numeric(trim($value, SINGLEQUOTE))) {
+ /// Non numeric string, prepend our dear N
+ $literals[$key] = 'N' . trim($value, 'N'); //Trimming potentially existing previous "N"
+ }
+ }
+ }
+
+ /// Re-apply literals to the text
+ if (!empty($literals)) {
+ $result = str_replace(array_keys($literals), $literals, $result);
+ }
+
+ /// Any pairs followed by N' must be switched to N' followed by those pairs
+ /// (or strings beginning with single quotes will fail)
+ $result = preg_replace("/((<@#@#@PAIR-(\d+)@#@#@>)+)N'/", "N'$1", $result);
+
+ /// Re-apply pairs of single-quotes to the text
+ if (!empty($pairs)) {
+ $result = str_replace(array_keys($pairs), $pairs, $result);
+ }
+
+ /// Print transformation if debug = on
+ if ($result != $sql && $this->debug) {
+ ADOConnection::outp("{$this->databaseType} internal transformation:<br>{$sql}<br>to<br>{$result}");
+ }
+
+ return $result;
+ }
+}
+
+class ADORecordset_mssql_n extends ADORecordset_mssql {
+ var $databaseType = "mssql_n";
+ function ADORecordset_mssql_n($id,$mode=false)
+ {
+ $this->ADORecordset_mssql($id,$mode);
+ }
+}
+?>
\ No newline at end of file
<?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.
<?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.
// 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) {
<?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.
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()
{
//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) . "'";
}
+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
<?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.
<?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.
First cut at the Netezza Driver by Josh Eldridge joshuae74#hotmail.com
Based on the previous postgres drivers.
<?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,
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
$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;
}
if ($inputarr) {
#if (!is_array($inputarr)) $inputarr = array($inputarr);
-
$element0 = reset($inputarr);
# is_object check because oci8 descriptors can be passed in
<?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.
<?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.
<?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.
<?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.
<?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.
var $substr = 'substring';
var $length = 'len';
var $ansiOuter = true; // for mssql7 or later
- var $identitySQL = 'select @@IDENTITY'; // 'select SCOPE_IDENTITY'; # for mssql 2000
+ var $identitySQL = 'select SCOPE_IDENTITY()'; // 'select SCOPE_IDENTITY'; # for mssql 2000
var $hasInsertID = true;
var $connectStmt = 'SET CONCAT_NULL_YIELDS_NULL OFF'; # When SET CONCAT_NULL_YIELDS_NULL is ON,
# concatenating a null value with a string yields a NULL result
}
// crashes php...
- //Note replaced by some different code to allow it to work properly
- //for Moode environmental checks
function ServerInfo()
{
+ global $ADODB_FETCH_MODE;
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
$row = $this->GetRow("execute sp_server_info 2");
-
- $arr['description'] = $row['attribute_value'];
+ $ADODB_FETCH_MODE = $save;
+ if (!is_array($row)) return false;
+ $arr['description'] = $row[2];
$arr['version'] = ADOConnection::_findvers($arr['description']);
return $arr;
}
<?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.
<?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.
$this->_canSelectDb = true;
$this->substr = "substring";
$this->length = 'len';
- $this->identitySQL = 'select @@IDENTITY';
+ $this->identitySQL = 'select SCOPE_IDENTITY()';
$this->metaDatabasesSQL = "select name from master..sysdatabases where name <> 'master'";
$this->_canPrepareSP = true;
break;
$this->rightOuter = '=*';
$this->hasInsertID = true;
$this->hasTransactions = true;
- $this->identitySQL = 'select @@IDENTITY';
+ $this->identitySQL = 'select SCOPE_IDENTITY()';
break;
default:
$this->databaseType = 'odbtp';
<?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.
<?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.
<?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.
/*
-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.
/*
-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.
/*
-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.
<?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.
<?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.
<?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.
<?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.
<?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.
<?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.
<?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.
<?php
/*
-version V4.94 23 Jan 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights
+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,
<?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.
<?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.
<?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.
<?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.
<?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.
<?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.
<?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.
<?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.
<?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.
<?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.
'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
);
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>.';
}
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);
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
<?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.
$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);
-Description of ADODB v4.95a library import into Moodle
+Description of ADODB v4.96a library import into Moodle
Removed:
* contrib/
Added:
* index.html - prevent directory browsing on misconfigured servers
- * tests/tmssql.php - detection of attack attempts and overwrite on incorrectly upgraded sites
* readme_moodle.txt - this file ;-)
Our changes:
* adodb-lib.inc.php - modify some debug output to be correct XHTML. MDL-12378.
Reported to ADOdb at: http://phplens.com/lens/lensforum/msgs.php?id=17133
Once fixed by adodb guys, we'll return to their official distro.
- * drivers/adodb-mssql_n.inc.php - Fixed one bug in the N' parser when one value start by '
- Once fixed by adodb guys, we'll return to their official distro.
- * drivers/adodb-odbc_mssql.inc.php - Fixed one buggy function (ServerInfo) that was not
- working properly. Simplified logic (now that we are FETCH_ASSOC). Work in progress
- for the annoying http://tracker.moodle.org/browse/MDL-6877.
- Once fixed by adodb guys, we'll return to their official distro.
* lang/adodb-ar.inc.php lang/adodb-bg.inc.php lang/adodb-bgutf8.inc.php
lang/adodb-en.inc.php lang/adodb-pl.inc.php lang/adodb-ro.inc.php
lang/adodb_th.inc.php - Removed leading white space outside PHP open/close tags
(see http://tracker.moodle.org/browse/MDL-11632).
-skodak,iarenaza
+skodak, iarenaza
$Id$
<?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.
Contributed by Ross Smith (adodb@netebb.com).
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
/*
-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.
Contributed by Ross Smith (adodb@netebb.com).
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
/*
-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.
Contributed by Ross Smith (adodb@netebb.com).
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
/*
-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.
Contributed by Ross Smith (adodb@netebb.com).
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
/*
-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.
Contributed by Ross Smith (adodb@netebb.com).
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
<?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.
Contributed by Ross Smith (adodb@netebb.com).
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
<?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.
Contributed by Ross Smith (adodb@netebb.com).
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
/*
-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.
Contributed by Ross Smith (adodb@netebb.com).
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
/*
-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.
Contributed by Ross Smith (adodb@netebb.com).
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
/*
-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.
Contributed by Ross Smith (adodb@netebb.com).
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
// now we only update expiry date, thx to sebastian thom in adodb 2.32
if ($crc !== false && $crc == (strlen($val) . crc32($val))) {
if ($debug) {
- echo '<p>Session: Only updating date - crc32 not changed</p>';
+ ADOConnection::outp( '<p>Session: Only updating date - crc32 not changed</p>');
}
$expirevar = '';
/*
-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.
Contributed by Ross Smith (adodb@netebb.com).
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
<?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.