core

Changeset 24912

Show
Ignore:
Timestamp:
11/26/08 10:11:56 (6 weeks ago)
Author:
Guite
Message:

updated adodb to 4.991 for 1.1.0, cleaned up redundant docs, overhauled documentation of customizations, refs #387 - adodb updates

Location:
development/zikula-1/includes/classes/adodb
Files:
4 added
8 removed
101 modified
1 moved

Legend:

Unmodified
Added
Removed
  • development/zikula-1/includes/classes/adodb/adodb-active-record.inc.php

    r23689 r24912  
    22/* 
    33 
    4 @version V4.97 22 Jan 2008  (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved. 
     4@version v4.991 16 Oct 2008  (c) 2000-2008 John Lim (jlim#natsoft.com). All rights reserved. 
    55  Latest version is available at http://adodb.sourceforge.net 
    66  
     
    347347        } 
    348348         
     349        // I have an ON INSERT trigger on a table that sets other columns in the table. 
     350        // So, I find that for myTable, I want to reload an active record after saving it. -- Malcolm Cook 
     351        function Reload() 
     352        { 
     353                $db =& $this->DB(); if (!$db) return false; 
     354                $table =& $this->TableInfo(); 
     355                $where = $this->GenWhere($db, $table); 
     356                return($this->Load($where)); 
     357        } 
     358         
    349359        // set a numeric array (using natural table field ordering) as object properties 
    350360        function Set(&$row) 
     
    413423                        if (empty($val)) return 'null'; 
    414424                         
     425                case 'B': 
     426                case 'N': 
    415427                case 'C': 
    416428                case 'X': 
  • development/zikula-1/includes/classes/adodb/adodb-csvlib.inc.php

    r23689 r24912  
    99/*  
    1010 
    11   V4.97 22 Jan 2008  (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved. 
     11  v4.991 16 Oct 2008  (c) 2000-2008 John Lim (jlim#natsoft.com). All rights reserved. 
    1212  Released under both BSD license and Lesser GPL library license.  
    1313  Whenever there is any discrepancy between the two licenses,  
     
    265265        */ 
    266266        function adodb_write_file($filename, $contents,$debug=false) 
    267         {  
     267        { 
    268268        # http://www.php.net/bugs.php?id=9203 Bug that flock fails on Windows 
    269269        # So to simulate locking, we assume that rename is an atomic operation. 
     
    286286                        else $ok = false; 
    287287                        fclose($fd); 
    288                          
     288 
    289289                        if ($ok) { 
    290                                 chmod($tmpname,0644); 
     290                                @chmod($tmpname,0644); 
    291291                                // the tricky moment 
    292292                                @unlink($filename); 
     
    306306                        else $ok = false; 
    307307                        fclose($fd); 
    308                         chmod($filename,0644); 
     308                        @chmod($filename,0644); 
    309309                }else { 
    310310                        fclose($fd); 
  • development/zikula-1/includes/classes/adodb/adodb-datadict.inc.php

    r23689 r24912  
    22 
    33/** 
    4   V4.97 22 Jan 2008  (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved. 
     4  v4.991 16 Oct 2008  (c) 2000-2008 John Lim (jlim#natsoft.com). All rights reserved. 
    55  Released under both BSD license and Lesser GPL library license.  
    66  Whenever there is any discrepancy between the two licenses,  
     
    986986                                 && (isset($flds[0][2]) && is_numeric($flds[0][2]))) { 
    987987                                        if ($this->debug) ADOConnection::outp(sprintf("<h3>%s cannot be changed to %s currently</h3>", $flds[0][0], $flds[0][1])); 
    988                                         #echo "<h3>$this->alterCol cannot be changed to $flds currently</h3>"; 
     988                                        //echo "<h3>$this->alterCol cannot be changed to $flds currently</h3>"; 
    989989                                        continue;         
    990990                                } 
  • development/zikula-1/includes/classes/adodb/adodb-errorhandler.inc.php

    r23689 r24912  
    11<?php 
    22/** 
    3  * @version V4.97 22 Jan 2008  (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved. 
     3 * @version v4.991 16 Oct 2008  (c) 2000-2008 John Lim (jlim#natsoft.com). All rights reserved. 
    44 * Released under both BSD license and Lesser GPL library license. 
    55 * Whenever there is any discrepancy between the two licenses, 
  • development/zikula-1/includes/classes/adodb/adodb-error.inc.php

    r23689 r24912  
    11<?php 
    22/**  
    3  * @version V4.97 22 Jan 2008 (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved. 
     3 * @version v4.991 16 Oct 2008 (c) 2000-2008 John Lim (jlim#natsoft.com). All rights reserved. 
    44 * Released under both BSD license and Lesser GPL library license.  
    55 * Whenever there is any discrepancy between the two licenses,  
  • development/zikula-1/includes/classes/adodb/adodb-errorpear.inc.php

    r23689 r24912  
    11<?php 
    22/**  
    3  * @version V4.97 22 Jan 2008 (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved. 
     3 * @version v4.991 16 Oct 2008 (c) 2000-2008 John Lim (jlim#natsoft.com). All rights reserved. 
    44 * Released under both BSD license and Lesser GPL library license.  
    55  Whenever there is any discrepancy between the two licenses,  
  • development/zikula-1/includes/classes/adodb/adodb-exceptions.inc.php

    r23689 r24912  
    22 
    33/** 
    4  * @version V4.97 22 Jan 2008  (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved. 
     4 * @version v4.991 16 Oct 2008  (c) 2000-2008 John Lim (jlim#natsoft.com). All rights reserved. 
    55 * Released under both BSD license and Lesser GPL library license. 
    66 * Whenever there is any discrepancy between the two licenses, 
  • development/zikula-1/includes/classes/adodb/adodb.inc.php

    r23689 r24912  
    1 <?php  
     1<?php 
    22/* 
    33 * Set tabs to 4 for best viewing. 
     
    1515        \mainpage        
    1616         
    17          @version V4.97 22 Jan 2008  (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved. 
     17         @version v4.991 16 Oct 2008  (c) 2000-2008 John Lim (jlim#natsoft.com). All rights reserved. 
    1818 
    1919        Released under both BSD license and Lesser GPL library license. You can choose which license 
     
    5858                $ADODB_COMPAT_FETCH, // If $ADODB_COUNTRECS and this is true, $rs->fields is available on EOF 
    5959                $ADODB_FETCH_MODE,      // DEFAULT, NUM, ASSOC or BOTH. Default follows native driver default... 
     60                $ADODB_GETONE_EOF, 
    6061                $ADODB_QUOTE_FIELDNAMES; // Allows you to force quotes (backticks) around field names in queries generated by getinsertsql and getupdatesql.     
    6162         
     
    154155                $ADODB_CACHE_DIR,       // directory to cache recordsets 
    155156                $ADODB_FETCH_MODE, 
     157                $ADODB_GETONE_EOF, 
    156158                $ADODB_FORCE_TYPE, 
     159                $ADODB_CACHE_CLASS, 
     160                $ADODB_CACHE, 
    157161                $ADODB_QUOTE_FIELDNAMES; 
    158162                 
    159163                $ADODB_FETCH_MODE = ADODB_FETCH_DEFAULT; 
    160164                $ADODB_FORCE_TYPE = ADODB_FORCE_VALUE; 
    161  
    162  
     165                $ADODB_CACHE_CLASS = 'ADODB_Cache_File'; 
     166                $ADODB_GETONE_EOF = null; 
     167                 
    163168                if (!isset($ADODB_CACHE_DIR)) { 
    164169                        $ADODB_CACHE_DIR = '/tmp'; //(isset($_ENV['TMP'])) ? $_ENV['TMP'] : '/tmp'; 
     
    177182                 * ADODB version as a string. 
    178183                 */ 
    179                 $ADODB_vers = 'V4.97 22 Jan 2008 (c) 2000-2008 John Lim (jlim#natsoft.com.my). All rights reserved. Released BSD & LGPL.'; 
     184                $ADODB_vers = 'v4.991 16 Oct 2008 (c) 2000-2008 John Lim (jlim#natsoft.com). All rights reserved. Released BSD & LGPL.'; 
    180185         
    181186                /** 
     
    227232                } 
    228233        } 
     234         
     235        // class for caching 
     236        class ADODB_Cache_File { 
     237         
     238                var $createdir = true; // requires creation of temp dirs 
     239                 
     240                function ADODB_Cache_File() 
     241                { 
     242                global $ADODB_INCLUDED_CSV; 
     243                        if (empty($ADODB_INCLUDED_CSV)) include(ADODB_DIR.'/adodb-csvlib.inc.php'); 
     244                } 
     245                 
     246                // write serialised recordset to cache item/file 
     247                function writecache($filename, $contents,  $debug, $secs2cache) 
     248                { 
     249                        return adodb_write_file($filename, $contents,$debug); 
     250                } 
     251                 
     252                // load serialised recordset and unserialise it 
     253                function &readcache($filename, &$err, $secs2cache, $rsClass) 
     254                { 
     255                        $rs = csv2rs($filename,$err,$secs2cache,$rsClass); 
     256                        return $rs; 
     257                } 
     258                 
     259                // flush all items in cache 
     260                function flushall($debug=false) 
     261                { 
     262                global $ADODB_CACHE_DIR; 
     263 
     264                $rez = false; 
     265                 
     266                        if (strlen($ADODB_CACHE_DIR) > 1) { 
     267                                $rez = $this->_dirFlush($ADODB_CACHE_DIR); 
     268                        if ($debug) DOConnection::outp( "flushall: $dir<br><pre>\n". $rez."</pre>"); 
     269                        } 
     270                        return $rez; 
     271                } 
     272                 
     273                // flush one file in cache 
     274                function flushcache($f, $debug=false) 
     275                { 
     276                        if (!@unlink($f)) { 
     277                                if ($debug) ADOConnection::outp( "flushcache: failed for $f"); 
     278                        } 
     279                } 
     280                 
     281                function getdirname($hash) 
     282                { 
     283                global $ADODB_CACHE_DIR; 
     284                        if (!isset($this->notSafeMode)) $this->notSafeMode = !ini_get('safe_mode'); 
     285                        return ($this->notSafeMode) ? $ADODB_CACHE_DIR.'/'.substr($hash,0,2) : $ADODB_CACHE_DIR; 
     286                } 
     287                 
     288                // create temp directories 
     289                function createdir($hash, $debug) 
     290                { 
     291                        $dir = $this->getdirname($hash); 
     292                        if ($this->notSafeMode && !file_exists($dir)) { 
     293                                $oldu = umask(0); 
     294                                if (!@mkdir($dir,0771)) if(!is_dir($dir) && $debug) ADOConnection::outp("Cannot create $dir"); 
     295                                umask($oldu); 
     296                        } 
     297                 
     298                        return $dir; 
     299                } 
     300                 
     301                /** 
     302                * Private function to erase all of the files and subdirectories in a directory. 
     303                * 
     304                * Just specify the directory, and tell it if you want to delete the directory or just clear it out. 
     305                * Note: $kill_top_level is used internally in the function to flush subdirectories. 
     306                */ 
     307                function _dirFlush($dir, $kill_top_level = false)  
     308                { 
     309                   if(!$dh = @opendir($dir)) return; 
     310                    
     311                   while (($obj = readdir($dh))) { 
     312                                if($obj=='.' || $obj=='..') continue; 
     313                                $f = $dir.'/'.$obj; 
     314                 
     315                                if (strpos($obj,'.cache')) @unlink($f); 
     316                                if (is_dir($f)) $this->_dirFlush($f, true); 
     317                   } 
     318                   if ($kill_top_level === true) @rmdir($dir); 
     319                   return true; 
     320                } 
     321        } 
     322         
     323 
    229324         
    230325        //==============================================================================================         
     
    425520                 
    426521                $this->_isPersistentConnection = false;  
     522                 
     523                global $ADODB_CACHE; 
     524                if (empty($ADODB_CACHE)) $this->_CreateCache(); 
     525                                 
    427526                if ($forceNew) { 
    428527                        if ($rez=$this->_nconnect($this->host, $this->user, $this->password, $this->database)) return true; 
     
    441540                        $fn($this->databaseType,'CONNECT',$this->ErrorNo(),$err,$this->host,$this->database,$this); 
    442541                 
    443                  
    444542                $this->_connectionID = false; 
    445543                if ($this->debug) ADOConnection::outp( $this->host.': '.$err); 
     
    483581                        return $this->Connect($argHostname,$argUsername,$argPassword,$argDatabaseName); 
    484582                 
     583                 
    485584                if ($argHostname != "") $this->host = $argHostname; 
    486585                if ($argUsername != "") $this->user = $argUsername; 
     
    489588                         
    490589                $this->_isPersistentConnection = true;   
     590                 
     591                global $ADODB_CACHE; 
     592                if (empty($ADODB_CACHE)) $this->_CreateCache(); 
     593                                 
     594                                 
    491595                if ($rez = $this->_pconnect($this->host, $this->user, $this->password, $this->database)) return true; 
    492596                if (isset($rez)) { 
     
    505609                if ($this->debug) ADOConnection::outp( $this->host.': '.$err); 
    506610                return $ret; 
     611        } 
     612         
     613        // create cache class. Code is backward compat with old memcache implementation 
     614        function _CreateCache() 
     615        { 
     616        global $ADODB_CACHE, $ADODB_CACHE_CLASS; 
     617         
     618                if ($this->memCache) { 
     619                global $ADODB_INCLUDED_MEMCACHE; 
     620                 
     621                        if (empty($ADODB_INCLUDED_MEMCACHE)) include(ADODB_DIR.'/adodb-memcache.lib.inc.php'); 
     622                                $ADODB_CACHE = new ADODB_Cache_MemCache($this); 
     623                } else 
     624                                $ADODB_CACHE = new $ADODB_CACHE_CLASS($this); 
     625                 
    507626        } 
    508627 
     
    11801299                $ADODB_COUNTRECS = false; 
    11811300                         
    1182                 if ($offset>0){ 
    1183                         if ($secs2cache != 0) $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr); 
    1184                         else $rs = &$this->Execute($sql,$inputarr); 
    1185                 } else { 
    1186                         if ($secs2cache != 0) $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr); 
    1187                         else $rs = &$this->Execute($sql,$inputarr); 
    1188                 } 
     1301                if ($secs2cache != 0) $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr); 
     1302                else $rs = &$this->Execute($sql,$inputarr); 
     1303         
    11891304                $ADODB_COUNTRECS = $savec; 
    11901305                if ($rs && !$rs->EOF) { 
     
    12901405        } 
    12911406         
     1407                // $where should include 'WHERE fld=value' 
     1408        function GetMedian($table, $field,$where = '') 
     1409        {