]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-11471 adodb 4.96a import; merged from MOODLE_19_STABLE
authorskodak <skodak>
Wed, 2 Jan 2008 18:49:00 +0000 (18:49 +0000)
committerskodak <skodak>
Wed, 2 Jan 2008 18:49:00 +0000 (18:49 +0000)
93 files changed:
lib/adodb/adodb-active-record.inc.php
lib/adodb/adodb-csvlib.inc.php
lib/adodb/adodb-datadict.inc.php
lib/adodb/adodb-error.inc.php
lib/adodb/adodb-errorhandler.inc.php
lib/adodb/adodb-errorpear.inc.php
lib/adodb/adodb-exceptions.inc.php
lib/adodb/adodb-iterator.inc.php
lib/adodb/adodb-lib.inc.php
lib/adodb/adodb-pager.inc.php
lib/adodb/adodb-pear.inc.php
lib/adodb/adodb-perf.inc.php
lib/adodb/adodb-php4.inc.php
lib/adodb/adodb-time.inc.php
lib/adodb/adodb.inc.php
lib/adodb/datadict/datadict-access.inc.php
lib/adodb/datadict/datadict-db2.inc.php
lib/adodb/datadict/datadict-firebird.inc.php
lib/adodb/datadict/datadict-generic.inc.php
lib/adodb/datadict/datadict-ibase.inc.php
lib/adodb/datadict/datadict-informix.inc.php
lib/adodb/datadict/datadict-mssql.inc.php
lib/adodb/datadict/datadict-mysql.inc.php
lib/adodb/datadict/datadict-oci8.inc.php
lib/adodb/datadict/datadict-postgres.inc.php
lib/adodb/datadict/datadict-sybase.inc.php
lib/adodb/drivers/adodb-access.inc.php
lib/adodb/drivers/adodb-ado.inc.php
lib/adodb/drivers/adodb-ado5.inc.php
lib/adodb/drivers/adodb-ado_access.inc.php
lib/adodb/drivers/adodb-ado_mssql.inc.php
lib/adodb/drivers/adodb-borland_ibase.inc.php
lib/adodb/drivers/adodb-csv.inc.php
lib/adodb/drivers/adodb-db2.inc.php
lib/adodb/drivers/adodb-fbsql.inc.php
lib/adodb/drivers/adodb-firebird.inc.php
lib/adodb/drivers/adodb-ibase.inc.php
lib/adodb/drivers/adodb-informix.inc.php
lib/adodb/drivers/adodb-informix72.inc.php
lib/adodb/drivers/adodb-ldap.inc.php
lib/adodb/drivers/adodb-mssql.inc.php
lib/adodb/drivers/adodb-mssql_n.inc.php
lib/adodb/drivers/adodb-mssqlpo.inc.php
lib/adodb/drivers/adodb-mysql.inc.php
lib/adodb/drivers/adodb-mysqli.inc.php
lib/adodb/drivers/adodb-mysqlt.inc.php
lib/adodb/drivers/adodb-netezza.inc.php
lib/adodb/drivers/adodb-oci8.inc.php
lib/adodb/drivers/adodb-oci805.inc.php
lib/adodb/drivers/adodb-oci8po.inc.php
lib/adodb/drivers/adodb-odbc.inc.php
lib/adodb/drivers/adodb-odbc_db2.inc.php
lib/adodb/drivers/adodb-odbc_mssql.inc.php
lib/adodb/drivers/adodb-odbc_oracle.inc.php
lib/adodb/drivers/adodb-odbtp.inc.php
lib/adodb/drivers/adodb-odbtp_unicode.inc.php
lib/adodb/drivers/adodb-oracle.inc.php
lib/adodb/drivers/adodb-pdo.inc.php
lib/adodb/drivers/adodb-pdo_mssql.inc.php
lib/adodb/drivers/adodb-pdo_mysql.inc.php
lib/adodb/drivers/adodb-pdo_oci.inc.php
lib/adodb/drivers/adodb-pdo_pgsql.inc.php
lib/adodb/drivers/adodb-postgres.inc.php
lib/adodb/drivers/adodb-postgres64.inc.php
lib/adodb/drivers/adodb-postgres7.inc.php
lib/adodb/drivers/adodb-postgres8.inc.php
lib/adodb/drivers/adodb-proxy.inc.php
lib/adodb/drivers/adodb-sapdb.inc.php
lib/adodb/drivers/adodb-sqlanywhere.inc.php
lib/adodb/drivers/adodb-sqlite.inc.php
lib/adodb/drivers/adodb-sqlitepo.inc.php
lib/adodb/drivers/adodb-sybase.inc.php
lib/adodb/drivers/adodb-sybase_ase.inc.php
lib/adodb/drivers/adodb-vfp.inc.php
lib/adodb/perf/perf-db2.inc.php
lib/adodb/perf/perf-informix.inc.php
lib/adodb/perf/perf-mssql.inc.php
lib/adodb/perf/perf-mysql.inc.php
lib/adodb/perf/perf-oci8.inc.php
lib/adodb/perf/perf-postgres.inc.php
lib/adodb/readme_moodle.txt
lib/adodb/session/adodb-compress-bzip2.php
lib/adodb/session/adodb-compress-gzip.php
lib/adodb/session/adodb-cryptsession.php
lib/adodb/session/adodb-cryptsession2.php
lib/adodb/session/adodb-encrypt-mcrypt.php
lib/adodb/session/adodb-encrypt-md5.php
lib/adodb/session/adodb-encrypt-secret.php
lib/adodb/session/adodb-session-clob.php
lib/adodb/session/adodb-session-clob2.php
lib/adodb/session/adodb-session.php
lib/adodb/session/adodb-session2.php
lib/adodb/session/old/adodb-cryptsession.php

index 29b4da2062d3eef967f659bee9f1bdedfa03dbd1..a67b55e40cf507ed32de7b29f5af244054cc6f92 100644 (file)
@@ -1,7 +1,7 @@
 <?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. 
@@ -10,7 +10,7 @@
   
   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
@@ -340,9 +340,10 @@ class ADODB_Active_Record {
                        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;
index 1e34d39eef0d83991f002c68dc9fa65af235fa2f..77c4cc4bde4f962fa8a1d2971add11b525e18b74 100644 (file)
@@ -8,7 +8,7 @@ $ADODB_INCLUDED_CSV = 1;
 
 /* 
 
-  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. 
index f2c4661a6dd7e206ca45b4632626aac87c99ebf8..9761763a917ac91f47cc8ff4b74302684087f76a 100644 (file)
@@ -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.
index e60976b0d8e59421e8e446521bbc168541bab251..48e46ff2a3c50b2fa28c81439c34a24009f513ec 100644 (file)
@@ -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. 
index 87a9267c5ea82a10d47db74d97af9f874a061f86..3c844b7d59fcca5863d8c005aa1f782b45d5c83a 100644 (file)
@@ -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.
index 31cbe6141b4562c3c69866397e24ab8ff671a0cd..36b901c90a08e179cf2dc503120411ee33c55d10 100644 (file)
@@ -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. 
index 3eebc4e065219febec2df613ffa1e909ad70e3c4..53570abfc9abcb9cf8941c3ac5e41b2058db5338 100644 (file)
@@ -1,7 +1,7 @@
 <?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.
index d291e78a13638308acccae4560ecc1551fd06dd1..03df76124e5fb4bc28a2347a26d7c0fb41c129bc 100644 (file)
@@ -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.
index 222ecf064b8450aa249e970355825ed815e33b12..0fda05e43766feb1e5bac72b8b7a3d53d2f6d018 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-
+       
 // security - hide paths
 if (!defined('ADODB_DIR')) die();
 
@@ -7,7 +7,7 @@ global $ADODB_INCLUDED_LIB;
 $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 @@ $ADODB_INCLUDED_LIB = 1;
   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 @@ function _adodb_replace(&$zthis, $table, $fieldArray, $keyCol, $autoQuote, $has_
                        $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 @@ function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0)
         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 @@ function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0)
                                $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 @@ function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0)
        
        // 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];
                
@@ -980,11 +1004,11 @@ function _adodb_column_sql(&$zthis, $action, $type, $fname, $fnameq, $arrFields,
             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
@@ -1007,7 +1031,8 @@ function _adodb_debug_execute(&$zthis, $sql, $inputarr)
        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 ]";
        }
@@ -1152,4 +1177,4 @@ function _adodb_find_from($sql)
 }
 */
 
-?>
+?>
\ No newline at end of file
index 22321b2eb0ba2f4f77a0e35117c2f267e4bcee46..f7f6ba0e74c999a61d767dd717c3d2334da42834 100644 (file)
@@ -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. 
index ecaf75310c95b4c49d1d7a3fbdc6f5597cac0d3b..a2684f2073c0d33554b32203e1c34c72f067ad6b 100644 (file)
@@ -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. 
index e00359fcc1ae377df88b3e8672a09fd10544ff4f..fe070aa9ed7c78ce9afa7bd54f7e8c32316f1b14 100644 (file)
@@ -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 @@ Committed_AS:   348732 kB
                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 @@ Committed_AS:   348732 kB
        $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 @@ Committed_AS:   348732 kB
                switch ($do) {
                default:
                case 'stats':
+               
+                       if (empty($ADODB_LOG_CONN))
+                               echo "<p>&nbsp; <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% 
index 99fda1769996f2a96cc134de9b1a1668c343552a..a609770bcc4fd450a4beba552108f91f44bb1dd6 100644 (file)
@@ -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.
index 51f69f76c673eda7a431003ab66856025d972611..8e93018be6838f3c79847b6d8cd498e09a69c94b 100644 (file)
@@ -241,6 +241,14 @@ b. Implement daylight savings, which looks awfully complicated, see
 
 
 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,7 +376,9 @@ First implementation.
 /*
        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 
@@ -387,10 +397,13 @@ if (!defined('ADODB_ALLOW_NEGATIVE_TS')) define('ADODB_NO_NEGATIVE_TS',1);
 
 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 @@ function adodb_date_test_strftime($fmt)
        
        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 @@ function adodb_date_test()
        // 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 @@ function adodb_date_test()
        
        // 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 @@ function adodb_year_digit_check($y)
        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 @@ function adodb_validdate($y,$m,$d)
 {
 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 @@ function _adodb_getdate($origd=false,$fast=false,$is_gmt=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;
@@ -927,6 +979,23 @@ global $_month_table_normal,$_month_table_leaf;
                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)
 {
@@ -958,6 +1027,7 @@ function adodb_date2($fmt, $d=false, $is_gmt=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')) {
@@ -992,7 +1062,14 @@ static $daylight;
        */
        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 @@ static $daylight;
                        
                        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 @@ static $daylight;
                        
                // 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 @@ function adodb_mktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=fa
                        }
        }
        
-       $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.
index 1e7c94ed0f32bed7603ef8aaaced254c8bd5ce90..cb969e92b20b23361bbd0023e3acbcbc9151a73a 100644 (file)
@@ -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.
                /**
                 * 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.
index 4b62eb848155e47ccae2e11315cbd88c0675185a..908d6917e0664470e8227d9a973bf7302560718b 100644 (file)
@@ -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.
index 21191b35b527b9684681970c9536ebf2370ad1d8..ee2f0ec1e97b4fde2a825b2bec1e2b0ce79425c8 100644 (file)
@@ -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.
index 6598d95aeb17c7008e3251c9ea9adc1115150372..b2870c780510b0fc74fad10f5be61b27b33b5ef7 100644 (file)
@@ -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.
index fc5ba76849c0fc5664174385067ae354d9250915..902eeffefd332ceeb078019a1caa5a802d5460f4 100644 (file)
@@ -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.
index 163ba81d7000cc751686a31ead5f05a23c47f005..043f782d811aab9cdc6312eb5b7756924e5073eb 100644 (file)
@@ -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.
index 879813bed264ed58f4fce401742b19a2511c33e9..197f4498350c679e57cb8f687ab935649d3890a0 100644 (file)
@@ -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.
index 5737c27ad1ef3621f4635971cd16b1fe912e304e..2cf79f2670e27c6a7fc1dfa15203422e6cfb0409 100644 (file)
@@ -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.
index a4af25ff006db2f9bca78f83ef4f4f9a505607e4..477f36ac64501073ec0d64464ff522845ec402ef 100644 (file)
@@ -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.
index 238fab47c69f4ccd9ffdb7a5fc29b90e22fd8f03..5a2c4e2a162d81262f95efb0f45ba0354df91e95 100644 (file)
@@ -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.
index c56d3b6e7f5b00d777b18216fa4c2992d1fd512e..9421f3de2ec37203395e4c1f8228f218840beaf8 100644 (file)
@@ -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.
@@ -162,13 +162,68 @@ class ADODB2_postgres extends ADODB_DataDict {
         * @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);
        }
        
        /**
@@ -293,6 +348,20 @@ class ADODB2_postgres extends ADODB_DataDict {
                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 [, ... ] ]
index 4d2150212a5becf3e3ddc2d1da5f02552dd0783d..50300944ff3bb0b23ac3448a93e23cef51ca6faf 100644 (file)
@@ -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.
index 0b2cb2b23970572d9f1159d0cde4caf478b7bf38..0617874649796529d47329685243640c48631908 100644 (file)
@@ -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. 
index 4d730f273735031b3b04b9f63da807079e0292fe..d331a303d9e3ef9ffa5d11b8c98e7da34c8d1f8e 100644 (file)
@@ -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 @@ class ADORecordSet_ado extends ADORecordSet {
                                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;
index bfcf7c26e09bf6040959d10c8ed75130b590e50b..8ed40afb889a6abf10cefa696b2c75cacedaf1be 100644 (file)
@@ -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 @@ class ADORecordSet_ado extends ADORecordSet {
                                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;
index ab83e26df4c131f81954dff0459a7a6b0f992c09..1b93c69cf32cc25322d4297afaf71d40cb34114a 100644 (file)
@@ -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. 
index 576223d5c2372486dabe32492824ce099d97abac..1befc60af779454bb6a353e4e61383a51ad0325b 100644 (file)
@@ -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 @@ class  ADODB_ado_mssql extends ADODB_ado {
        
        function _insertid()
        {
-               return $this->GetOne('select @@identity');
+               return $this->GetOne('select SCOPE_IDENTITY()');
        }
        
        function _affectedrows()
index ab15feff39e48e3e254c9bbfcd816e7081d8ff8b..7fa75c441294bd00101e72abb4b74b3a328d51fc 100644 (file)
@@ -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. 
index a977416f5cd5bc1709e0b8898ed7231ce944588f..cb18601659c2022dd6b2e930f66d4323ff444427 100644 (file)
@@ -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.
index 1a86a1d2219c3f9d62387e6ddbc10ad89a42f5b9..acccf9012baf70e5d07357692e3392d0e985d853 100644 (file)
@@ -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
index 6a19bc202289bb2addf5ec7f804d2ddd5652e2bd..042099c173936422a17a2ba14ec125dad30eee92 100644 (file)
@@ -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. 
index 9b7b59ee10d359edf6c091851d4640088ca9754d..c67f5934907ca4fbf03ca3370e7a7a0326dfde02 100644 (file)
@@ -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. 
index 335493d90d8ef1dd5691fc41061fdcd765fc1641..8bb8ca459015f261d61b5667e1f6e996b3b7ff41 100644 (file)
@@ -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.
index eed00b056f1ad8a37f9d8eeef97bb764cdb0c093..f709cd06b37e9fe40d0781e05e72cec92321ec37 100644 (file)
@@ -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.
index 3bf65ef9b4d526fc33bc58d55ff5de871a6bae11..985c77dd105535db78ea9fca254e719b01b5cf7f 100644 (file)
@@ -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.
index bbf0cbf02f6b4d4526fde477cce5552ac8a4b9b2..23ec332750e44fd59454e4ed83871a11cdd581bf 100644 (file)
@@ -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.
@@ -39,13 +39,15 @@ class ADODB_ldap extends ADOConnection {
 
        # 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;
@@ -58,7 +60,7 @@ class ADODB_ldap extends ADOConnection {
                    $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;
@@ -70,14 +72,14 @@ class ADODB_ldap extends ADOConnection {
                }
                
                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;
@@ -149,10 +151,20 @@ class ADODB_ldap extends ADOConnection {
        /* 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()
index 8eebd914b168ca9056172fbbc09608bfbab4472c..f345b446c68781b089bf7a5eedb540eb3f5e4454 100644 (file)
@@ -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. 
@@ -33,6 +33,11 @@ if (!defined('ADODB_DIR')) die();
 //      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.
 //----------------------------------------------------------------
 
 
@@ -99,7 +104,7 @@ class ADODB_mssql extends ADOConnection {
        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;
        
index e740aacffab2b3b1fd56bcca3a8275d7c9b30d71..5a4c9deb49214e1eccd589e3236f0c407db62acc 100644 (file)
-<?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
index df482860b5bb6c90e526bd21bf530cd56dcc838a..2a632d2dd9f5c460c1c52f9bcf9c86c80652c301 100644 (file)
@@ -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.
index a9103523e810232afddd8fb54a72b49bf39e2d20..ac9d8fd00a2afc2a0a3740859bd0b86a22109bf9 100644 (file)
@@ -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 @@ class ADODB_mysql extends ADOConnection {
        // 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) {
index eea763438c60773d765422dcc2b109ec06b8ad16..6c86544567452a7ba744c4f24b147b571f764f1c 100644 (file)
@@ -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 @@ class ADODB_mysqli extends ADOConnection {
        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 @@ class ADODB_mysqli extends ADOConnection {
        //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_mysqli extends ADORecordSet{
  
 }
 
+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
index 9f1b53a799a1dd894900889f9ce71b4f335d57d7..fe05a174dc807949d97d7e7f1c42ba2bb6a3518b 100644 (file)
@@ -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.
index eedf51dfe8e6552c2f5ec6a460d52a3bc987874b..66c92d029317eae789a417d632f191146d385b9c 100644 (file)
@@ -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.
  
   First cut at the Netezza Driver by Josh Eldridge joshuae74#hotmail.com
  Based on the previous postgres drivers.
index b86c10b781cfd0508a0b550511478a9cc099c43c..ea84884628dc412a63ac3fbef03ce418628a017b 100644 (file)
@@ -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 @@ NATSOFT.DOMAIN =
                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 @@ NATSOFT.DOMAIN =
                                $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 @@ NATSOFT.DOMAIN =
                }
                if ($inputarr) {
                        #if (!is_array($inputarr)) $inputarr = array($inputarr);
-                       
                        $element0 = reset($inputarr);
                        
                        # is_object check because oci8 descriptors can be passed in
index 8da0ba19800acfa9d43fa78c668a8c6eb37a876a..8d3513fb7b3e144b97effe4c71c9ef4310ac4692 100644 (file)
@@ -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. 
index 2432f395a1a9fd9485b2ef6f1eaa29dbddf2baef..521685ad2d9faf6e9a2a5ec387b1f66abd9dc56c 100644 (file)
@@ -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.
index d8b8f18599193e183c6033f21a7e2fbe9e90b43e..dff6182b2265ad71be6e0da4738122ea2690e9cb 100644 (file)
@@ -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. 
index 3ae91d7a325f1ede5572b22926c315e5d22c52a1..91dec31ffdd8d9b2fdc3321514ba0ddf4b53628e 100644 (file)
@@ -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. 
index ce36d2e394db7554fbd3390f705e774e5569a526..e57b18da2347ef931ddcd6afe6969d6fadd56501 100644 (file)
@@ -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. 
@@ -35,7 +35,7 @@ class  ADODB_odbc_mssql extends ADODB_odbc {
        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
@@ -47,13 +47,15 @@ class  ADODB_odbc_mssql extends ADODB_odbc {
        }
 
        // 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;
        }
index cb29f0b20fadc8247ead34ede1adbccc1ddd9e3c..47af47721439b3934e52845e0d0c7eac95547d27 100644 (file)
@@ -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. 
index 6f52ae772ed726909ad06ff4a921c63e6661155f..e8799739a09aa17953a3913921e37e6c0d6a706f 100644 (file)
@@ -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.
@@ -192,7 +192,7 @@ class ADODB_odbtp extends ADOConnection{
                                $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;
@@ -240,7 +240,7 @@ class ADODB_odbtp extends ADOConnection{
                                $this->rightOuter = '=*';
                                $this->hasInsertID = true;
                                $this->hasTransactions = true;
-                               $this->identitySQL = 'select @@IDENTITY';
+                               $this->identitySQL = 'select SCOPE_IDENTITY()';
                                break;
                        default:
                                $this->databaseType = 'odbtp';
index ff793733859b844e1bdc88182f0d8e4748ef99be..3c77882eac2e2b7a172daa56adb109135e26ddc8 100644 (file)
@@ -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.
index 3c9023ad030e262189ef403cd2aa502269e532de..870863bd06b88baec2a2d36919f57a21e909e996 100644 (file)
@@ -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.
index e3f77f1f8ed3cfb3d56ec6203b033bca7f6de1cf..3946107d620fa8486d91802e1afb0ceb800531f9 100644 (file)
@@ -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. 
index 9470dd8f07abc3f7d100e4f68fae814275749013..3450b4b05b237225f802c6fcbcc06778dd3e46b5 100644 (file)
@@ -2,7 +2,7 @@
 
 
 /*
-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.
index b80241df04d9ebf358d53af8cec7fcda2314064c..701d7f30ba10e121e08119fe583832087cb3480d 100644 (file)
@@ -2,7 +2,7 @@
 
 
 /*
-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.
index 9d40f14ab4e40ed6da60debd890527df64dbfd97..50112db25f2e50766500940e9fa76c1dd41d348e 100644 (file)
@@ -2,7 +2,7 @@
 
 
 /*
-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.
index e802d799e2cec30f470758da83a7e1aea1fed92e..039bd83f1695d083acea3f83f4310779a3fcbd6a 100644 (file)
@@ -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.
index 5e8ce48e05b40f1c4b686e8fafabb997ff83cf00..7bad1f0a2ecb3a89af522190037cd71868b739fc 100644 (file)
@@ -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.
index 69d44fc7d71ef8616c02bd1fb3aa5af7a292f160..ed4a5cce4720fff738d74d725e024f03e95856b3 100644 (file)
@@ -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.
index 5c3d7bb63ba7457b7a1dab70bc3452da0336305a..e53999fb288d4b4a972d40bf704e42da3b1453c6 100644 (file)
@@ -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.
index f3712a3947a45954bd4e2befd8663c71cdfb5eee..05bccf44dd5120a52cb414c06b42722d54190394 100644 (file)
@@ -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.
index 022a64ee388cb34a66fc2e6ff4ade9d61dba528e..0bada7bdd6e9c9601f03b06bea5fc1374f642603 100644 (file)
@@ -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.
index 493893e4ad96cf0e2efd9cff3292279a635ee0ad..57c8972aba3e84d44428914510460ce4d4411ccb 100644 (file)
@@ -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. 
index 88af3ae689683f972b3930f1c768ff893ea826bf..53dae9979dd8e0a09072b94a4642e067a4d6c528 100644 (file)
@@ -1,6 +1,6 @@
 <?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, 
index 665cc543828d9906477a60fc710fb4bfd1411479..c5dbacfd88206a02577027e84a887b9722be4e58 100644 (file)
@@ -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.
index dbd0271b0ffadb9616fe318670d0f6fda4ab1909..436af4b58a99a80e89a6f288656c8420ee7cc1b6 100644 (file)
@@ -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.
index ba6b91922446f88a400e790a39b293e5cc80ec88..0802669c66aa100d7ab116a8a8b1a1e659669aad 100644 (file)
@@ -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. 
index 9b5334d30a9660212863446dd565e24ead3a2bec..84213cd6aca2df913461768a7e76039863a9a434 100644 (file)
@@ -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.
index 034eee2f09b1cb0213ba70d0dd9c93d4cf2bcedb..e3cd6518cb45ff71773a463815af22687fcf72c5 100644 (file)
@@ -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. 
index 9c8e77265a0259e5e522228b8e5c3af319a136d7..ca02cb554ec7d42bfd7e2e30db7efc573348ea6b 100644 (file)
@@ -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. 
index d5e47578921dd55418df292de5c4438d30edee1d..9893a515efd7cdcf09e64e3a02f3ed5648de516e 100644 (file)
@@ -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. 
index f2dfa7ba63dd0b5ec1f7c912a95662f1ac100594..b737e1ffede4bf7e6e968d64e33e6de5ddb3327e 100644 (file)
@@ -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. 
index 50639d957203a72459c6287a2cb4710b3a86c948..a5f44072e518b3fc03296eee01a28215e61f27c5 100644 (file)
@@ -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. 
index 19df7a2b44c4d2fab2437a8c3874fb95325d5f74..cf560f06f3cfb6be279af65e992199647bb39072 100644 (file)
@@ -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 @@ having count(*) > 100)",'These are sql statements that should be using bind vari
                '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 @@ having count(*) > 100)",'These are sql statements that should be using bind vari
                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 @@ CREATE TABLE PLAN_TABLE (
        
                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 @@ order by
                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
index da41ebe4bfdb84abdff54b7f63e5d9730ca73743..fa8b2ca5afa43a988168cbbf689973fb4a01ae7a 100644 (file)
@@ -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 @@ class perf_postgres extends adodb_perf{
                $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);
index d32a518a4a20720e020502d302a1766770a84a80..45d08c4edddef492259e74bb5b883620a9996c36 100644 (file)
@@ -1,4 +1,4 @@
-Description of ADODB v4.95a library import into Moodle
+Description of ADODB v4.96a library import into Moodle
 
 Removed:
  * contrib/
@@ -10,7 +10,6 @@ Removed:
 
 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:
@@ -18,18 +17,12 @@ 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$
index 79c3823f7f3b2e48798cc6412e6ebe54918bdd69..cbb5c4e16f72c20fd0e27f382aa8a32d041e4d10 100644 (file)
@@ -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.
          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,
index da8d3d4e535dceac793d6f1bd61af4f51c4b9ec7..d39ef0ec6b0c13f0d5c7ea0fe939df8a0ed3ec2a 100644 (file)
@@ -2,7 +2,7 @@
 
 
 /*
-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,
index ddf619dd885171efc85924f63336ed872a6d0d73..2d7240bc873439699d8100de1c26813991e9ecf0 100644 (file)
@@ -2,7 +2,7 @@
 
 
 /*
-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,
index 6334eaf8a57788f38d679bd3edd29e7438dd6891..379a850bc4b99fae3c4f730858217b29a9ebd1fe 100644 (file)
@@ -2,7 +2,7 @@
 
 
 /*
-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,
index a047579f073a52e07c4e3a09a00e7510ba893ee7..a88b537073eee5058a80f9f684e53ccad4406753 100644 (file)
@@ -2,7 +2,7 @@
 
 
 /*
-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,
index 24caa6620b6b2bcd6faaf5e253d4d84072f6b637..2e0d0d0340c298a2ca8d35ddf7f7b4c0ee0a31cb 100644 (file)
@@ -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.
          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,
index cc7e2fb257b5c48a311497e722229868f4c27868..b7798eecb083312a6675a6821dcc440d4aa893c3 100644 (file)
@@ -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.
          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,
index a2cd480025252e6e40064e71cdee9f8527e669e7..ec0fcd11fcf32384037a21e4dd230041c718ee1a 100644 (file)
@@ -2,7 +2,7 @@
 
 
 /*
-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,
index 54b80439eaf9727cc470ad3058179d8527633e70..484e555b6727a8344467591e83b35cca44c0429f 100644 (file)
@@ -2,7 +2,7 @@
 
 
 /*
-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,
index f0054ef878f4eb8c85d792ffbca535d759adbb3c..d24089e48dede52b9374a0fc630abb9d98add415 100644 (file)
@@ -2,7 +2,7 @@
 
 
 /*
-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,
@@ -666,7 +666,7 @@ class ADODB_Session {
                // 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 = '';
index e4ac07d3d857570228b6aec8af3bb44953f98320..c36f5a3fa873d0fcca8e44fb6a792d590e9ed536 100644 (file)
@@ -2,7 +2,7 @@
 
 
 /*
-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,
index 40ce283be3e4d7edad69c3eecf36fef225bba75e..316c722314f16d10f7d884ee125be9a134a83ffa 100644 (file)
@@ -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.