Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]
1 <?php 2 /* 3 @version v5.20.16 12-Jan-2020 4 @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved. 5 @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community 6 Released under both BSD license and Lesser GPL library license. 7 Whenever there is any discrepancy between the two licenses, 8 the BSD license will take precedence. 9 Set tabs to 4. 10 11 Currently unsupported: MetaDatabases, MetaTables and MetaColumns, and also inputarr in Execute. 12 Native types have been converted to MetaTypes. 13 Transactions not supported yet. 14 15 Limitation of url length. For IIS, see MaxClientRequestBuffer registry value. 16 17 http://support.microsoft.com/default.aspx?scid=kb;en-us;260694 18 */ 19 20 // security - hide paths 21 if (!defined('ADODB_DIR')) die(); 22 23 if (! defined("_ADODB_CSV_LAYER")) { 24 define("_ADODB_CSV_LAYER", 1 ); 25 26 include_once (ADODB_DIR.'/adodb-csvlib.inc.php'); 27 28 class ADODB_csv extends ADOConnection { 29 var $databaseType = 'csv'; 30 var $databaseProvider = 'csv'; 31 var $hasInsertID = true; 32 var $hasAffectedRows = true; 33 var $fmtTimeStamp = "'Y-m-d H:i:s'"; 34 var $_affectedrows=0; 35 var $_insertid=0; 36 var $_url; 37 var $replaceQuote = "''"; // string to use to replace quotes 38 var $hasTransactions = false; 39 var $_errorNo = false; 40 41 function __construct() 42 { 43 } 44 45 function _insertid() 46 { 47 return $this->_insertid; 48 } 49 50 function _affectedrows() 51 { 52 return $this->_affectedrows; 53 } 54 55 function MetaDatabases() 56 { 57 return false; 58 } 59 60 61 // returns true or false 62 function _connect($argHostname, $argUsername, $argPassword, $argDatabasename) 63 { 64 if (strtolower(substr($argHostname,0,7)) !== 'http://') return false; 65 $this->_url = $argHostname; 66 return true; 67 } 68 69 // returns true or false 70 function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) 71 { 72 if (strtolower(substr($argHostname,0,7)) !== 'http://') return false; 73 $this->_url = $argHostname; 74 return true; 75 } 76 77 function MetaColumns($table, $normalize=true) 78 { 79 return false; 80 } 81 82 83 // parameters use PostgreSQL convention, not MySQL 84 function SelectLimit($sql, $nrows = -1, $offset = -1, $inputarr = false, $secs2cache = 0) 85 { 86 global $ADODB_FETCH_MODE; 87 88 $nrows = (int) $nrows; 89 $offset = (int) $offset; 90 $url = $this->_url.'?sql='.urlencode($sql)."&nrows=$nrows&fetch=". 91 (($this->fetchMode !== false)?$this->fetchMode : $ADODB_FETCH_MODE). 92 "&offset=$offset"; 93 $err = false; 94 $rs = csv2rs($url,$err,false); 95 96 if ($this->debug) print "$url<br><i>$err</i><br>"; 97 98 $at = strpos($err,'::::'); 99 if ($at === false) { 100 $this->_errorMsg = $err; 101 $this->_errorNo = (integer)$err; 102 } else { 103 $this->_errorMsg = substr($err,$at+4,1024); 104 $this->_errorNo = -9999; 105 } 106 if ($this->_errorNo) 107 if ($fn = $this->raiseErrorFn) { 108 $fn($this->databaseType,'EXECUTE',$this->ErrorNo(),$this->ErrorMsg(),$sql,''); 109 } 110 111 if (is_object($rs)) { 112 113 $rs->databaseType='csv'; 114 $rs->fetchMode = ($this->fetchMode !== false) ? $this->fetchMode : $ADODB_FETCH_MODE; 115 $rs->connection = $this; 116 } 117 return $rs; 118 } 119 120 // returns queryID or false 121 function _Execute($sql,$inputarr=false) 122 { 123 global $ADODB_FETCH_MODE; 124 125 if (!$this->_bindInputArray && $inputarr) { 126 $sqlarr = explode('?',$sql); 127 $sql = ''; 128 $i = 0; 129 foreach($inputarr as $v) { 130 131 $sql .= $sqlarr[$i]; 132 if (gettype($v) == 'string') 133 $sql .= $this->qstr($v); 134 else if ($v === null) 135 $sql .= 'NULL'; 136 else 137 $sql .= $v; 138 $i += 1; 139 140 } 141 $sql .= $sqlarr[$i]; 142 if ($i+1 != sizeof($sqlarr)) 143 print "Input Array does not match ?: ".htmlspecialchars($sql); 144 $inputarr = false; 145 } 146 147 $url = $this->_url.'?sql='.urlencode($sql)."&fetch=". 148 (($this->fetchMode !== false)?$this->fetchMode : $ADODB_FETCH_MODE); 149 $err = false; 150 151 152 $rs = csv2rs($url,$err,false); 153 if ($this->debug) print urldecode($url)."<br><i>$err</i><br>"; 154 $at = strpos($err,'::::'); 155 if ($at === false) { 156 $this->_errorMsg = $err; 157 $this->_errorNo = (integer)$err; 158 } else { 159 $this->_errorMsg = substr($err,$at+4,1024); 160 $this->_errorNo = -9999; 161 } 162 163 if ($this->_errorNo) 164 if ($fn = $this->raiseErrorFn) { 165 $fn($this->databaseType,'EXECUTE',$this->ErrorNo(),$this->ErrorMsg(),$sql,$inputarr); 166 } 167 if (is_object($rs)) { 168 $rs->fetchMode = ($this->fetchMode !== false) ? $this->fetchMode : $ADODB_FETCH_MODE; 169 170 $this->_affectedrows = $rs->affectedrows; 171 $this->_insertid = $rs->insertid; 172 $rs->databaseType='csv'; 173 $rs->connection = $this; 174 } 175 return $rs; 176 } 177 178 /* Returns: the last error message from previous database operation */ 179 function ErrorMsg() 180 { 181 return $this->_errorMsg; 182 } 183 184 /* Returns: the last error number from previous database operation */ 185 function ErrorNo() 186 { 187 return $this->_errorNo; 188 } 189 190 // returns true or false 191 function _close() 192 { 193 return true; 194 } 195 } // class 196 197 class ADORecordset_csv extends ADORecordset { 198 function __construct($id,$mode=false) 199 { 200 parent::__construct($id,$mode); 201 } 202 203 function _close() 204 { 205 return true; 206 } 207 } 208 209 } // define
title
Description
Body
title
Description
Body
title
Description
Body
title
Body