Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]
1 <?php 2 /* 3 @version v5.21.0 2021-02-27 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 _insertid() 42 { 43 return $this->_insertid; 44 } 45 46 function _affectedrows() 47 { 48 return $this->_affectedrows; 49 } 50 51 function MetaDatabases() 52 { 53 return false; 54 } 55 56 57 // returns true or false 58 function _connect($argHostname, $argUsername, $argPassword, $argDatabasename) 59 { 60 if (strtolower(substr($argHostname,0,7)) !== 'http://') return false; 61 $this->_url = $argHostname; 62 return true; 63 } 64 65 // returns true or false 66 function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) 67 { 68 if (strtolower(substr($argHostname,0,7)) !== 'http://') return false; 69 $this->_url = $argHostname; 70 return true; 71 } 72 73 function MetaColumns($table, $normalize=true) 74 { 75 return false; 76 } 77 78 79 // parameters use PostgreSQL convention, not MySQL 80 function SelectLimit($sql, $nrows = -1, $offset = -1, $inputarr = false, $secs2cache = 0) 81 { 82 global $ADODB_FETCH_MODE; 83 84 $nrows = (int) $nrows; 85 $offset = (int) $offset; 86 $url = $this->_url.'?sql='.urlencode($sql)."&nrows=$nrows&fetch=". 87 (($this->fetchMode !== false)?$this->fetchMode : $ADODB_FETCH_MODE). 88 "&offset=$offset"; 89 $err = false; 90 $rs = csv2rs($url,$err,false); 91 92 if ($this->debug) print "$url<br><i>$err</i><br>"; 93 94 $at = strpos($err,'::::'); 95 if ($at === false) { 96 $this->_errorMsg = $err; 97 $this->_errorNo = (integer)$err; 98 } else { 99 $this->_errorMsg = substr($err,$at+4,1024); 100 $this->_errorNo = -9999; 101 } 102 if ($this->_errorNo) 103 if ($fn = $this->raiseErrorFn) { 104 $fn($this->databaseType,'EXECUTE',$this->ErrorNo(),$this->ErrorMsg(),$sql,''); 105 } 106 107 if (is_object($rs)) { 108 109 $rs->databaseType='csv'; 110 $rs->fetchMode = ($this->fetchMode !== false) ? $this->fetchMode : $ADODB_FETCH_MODE; 111 $rs->connection = $this; 112 } 113 return $rs; 114 } 115 116 // returns queryID or false 117 function _Execute($sql,$inputarr=false) 118 { 119 global $ADODB_FETCH_MODE; 120 121 if (!$this->_bindInputArray && $inputarr) { 122 $sqlarr = explode('?',$sql); 123 $sql = ''; 124 $i = 0; 125 foreach($inputarr as $v) { 126 127 $sql .= $sqlarr[$i]; 128 if (gettype($v) == 'string') 129 $sql .= $this->qstr($v); 130 else if ($v === null) 131 $sql .= 'NULL'; 132 else 133 $sql .= $v; 134 $i += 1; 135 136 } 137 $sql .= $sqlarr[$i]; 138 if ($i+1 != sizeof($sqlarr)) 139 print "Input Array does not match ?: ".htmlspecialchars($sql); 140 $inputarr = false; 141 } 142 143 $url = $this->_url.'?sql='.urlencode($sql)."&fetch=". 144 (($this->fetchMode !== false)?$this->fetchMode : $ADODB_FETCH_MODE); 145 $err = false; 146 147 148 $rs = csv2rs($url,$err,false); 149 if ($this->debug) print urldecode($url)."<br><i>$err</i><br>"; 150 $at = strpos($err,'::::'); 151 if ($at === false) { 152 $this->_errorMsg = $err; 153 $this->_errorNo = (integer)$err; 154 } else { 155 $this->_errorMsg = substr($err,$at+4,1024); 156 $this->_errorNo = -9999; 157 } 158 159 if ($this->_errorNo) 160 if ($fn = $this->raiseErrorFn) { 161 $fn($this->databaseType,'EXECUTE',$this->ErrorNo(),$this->ErrorMsg(),$sql,$inputarr); 162 } 163 if (is_object($rs)) { 164 $rs->fetchMode = ($this->fetchMode !== false) ? $this->fetchMode : $ADODB_FETCH_MODE; 165 166 $this->_affectedrows = $rs->affectedrows; 167 $this->_insertid = $rs->insertid; 168 $rs->databaseType='csv'; 169 $rs->connection = $this; 170 } 171 return $rs; 172 } 173 174 /* Returns: the last error message from previous database operation */ 175 function ErrorMsg() 176 { 177 return $this->_errorMsg; 178 } 179 180 /* Returns: the last error number from previous database operation */ 181 function ErrorNo() 182 { 183 return $this->_errorNo; 184 } 185 186 // returns true or false 187 function _close() 188 { 189 return true; 190 } 191 } // class 192 193 class ADORecordset_csv extends ADORecordset { 194 195 function _close() 196 { 197 return true; 198 } 199 } 200 201 } // define
title
Description
Body
title
Description
Body
title
Description
Body
title
Body