[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /* 3 V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim#natsoft.com.my). All rights reserved. 4 Released under both BSD license and Lesser GPL library license. 5 Whenever there is any discrepancy between the two licenses, 6 the BSD license will take precedence. 7 Set tabs to 4. 8 9 Postgres7 support. 10 28 Feb 2001: Currently indicate that we support LIMIT 11 01 Dec 2001: dannym added support for default values 12 */ 13 14 // security - hide paths 15 if (!defined('ADODB_DIR')) die(); 16 17 include_once(ADODB_DIR."/drivers/adodb-postgres64.inc.php"); 18 19 class ADODB_postgres7 extends ADODB_postgres64 { 20 var $databaseType = 'postgres7'; 21 var $hasLimit = true; // set to true for pgsql 6.5+ only. support pgsql/mysql SELECT * FROM TABLE LIMIT 10 22 var $ansiOuter = true; 23 var $charSet = true; //set to true for Postgres 7 and above - PG client supports encodings 24 25 function ADODB_postgres7() 26 { 27 $this->ADODB_postgres64(); 28 if (ADODB_ASSOC_CASE !== 2) { 29 $this->rsPrefix .= 'assoc_'; 30 } 31 } 32 33 34 // the following should be compat with postgresql 7.2, 35 // which makes obsolete the LIMIT limit,offset syntax 36 function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) 37 { 38 $offsetStr = ($offset >= 0) ? " OFFSET $offset" : ''; 39 $limitStr = ($nrows >= 0) ? " LIMIT $nrows" : ''; 40 if ($secs2cache) 41 $rs =& $this->CacheExecute($secs2cache,$sql."$limitStr$offsetStr",$inputarr); 42 else 43 $rs =& $this->Execute($sql."$limitStr$offsetStr",$inputarr); 44 45 return $rs; 46 } 47 /* 48 function Prepare($sql) 49 { 50 $info = $this->ServerInfo(); 51 if ($info['version']>=7.3) { 52 return array($sql,false); 53 } 54 return $sql; 55 } 56 */ 57 58 // from Edward Jaramilla, improved version - works on pg 7.4 59 function MetaForeignKeys($table, $owner=false, $upper=false) 60 { 61 $sql = 'SELECT t.tgargs as args 62 FROM 63 pg_trigger t,pg_class c,pg_proc p 64 WHERE 65 t.tgenabled AND 66 t.tgrelid = c.oid AND 67 t.tgfoid = p.oid AND 68 p.proname = \'RI_FKey_check_ins\' AND 69 c.relname = \''.strtolower($table).'\' 70 ORDER BY 71 t.tgrelid'; 72 73 $rs = $this->Execute($sql); 74 75 if ($rs && !$rs->EOF) { 76 $arr =& $rs->GetArray(); 77 $a = array(); 78 foreach($arr as $v) 79 { 80 $data = explode(chr(0), $v['args']); 81 if ($upper) { 82 $a[strtoupper($data[2])][] = strtoupper($data[4].'='.$data[5]); 83 } else { 84 $a[$data[2]][] = $data[4].'='.$data[5]; 85 } 86 } 87 return $a; 88 } 89 return false; 90 } 91 92 93 94 // this is a set of functions for managing client encoding - very important if the encodings 95 // of your database and your output target (i.e. HTML) don't match 96 //for instance, you may have UNICODE database and server it on-site as WIN1251 etc. 97 // GetCharSet - get the name of the character set the client is using now 98 // the functions should work with Postgres 7.0 and above, the set of charsets supported 99 // depends on compile flags of postgres distribution - if no charsets were compiled into the server 100 // it will return 'SQL_ANSI' always 101 function GetCharSet() 102 { 103 //we will use ADO's builtin property charSet 104 $this->charSet = @pg_client_encoding($this->_connectionID); 105 if (!$this->charSet) { 106 return false; 107 } else { 108 return $this->charSet; 109 } 110 } 111 112 // SetCharSet - switch the client encoding 113 function SetCharSet($charset_name) 114 { 115 $this->GetCharSet(); 116 if ($this->charSet !== $charset_name) { 117 $if = pg_set_client_encoding($this->_connectionID, $charset_name); 118 if ($if == "0" & $this->GetCharSet() == $charset_name) { 119 return true; 120 } else return false; 121 } else return true; 122 } 123 124 } 125 126 /*-------------------------------------------------------------------------------------- 127 Class Name: Recordset 128 --------------------------------------------------------------------------------------*/ 129 130 class ADORecordSet_postgres7 extends ADORecordSet_postgres64{ 131 132 var $databaseType = "postgres7"; 133 134 135 function ADORecordSet_postgres7($queryID,$mode=false) 136 { 137 $this->ADORecordSet_postgres64($queryID,$mode); 138 } 139 140 // 10% speedup to move MoveNext to child class 141 function MoveNext() 142 { 143 if (!$this->EOF) { 144 $this->_currentRow++; 145 if ($this->_numOfRows < 0 || $this->_numOfRows > $this->_currentRow) { 146 $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode); 147 148 if (is_array($this->fields)) { 149 if ($this->fields && isset($this->_blobArr)) $this->_fixblobs(); 150 return true; 151 } 152 } 153 $this->fields = false; 154 $this->EOF = true; 155 } 156 return false; 157 } 158 159 } 160 161 class ADORecordSet_assoc_postgres7 extends ADORecordSet_postgres64{ 162 163 var $databaseType = "postgres7"; 164 165 166 function ADORecordSet_assoc_postgres7($queryID,$mode=false) 167 { 168 $this->ADORecordSet_postgres64($queryID,$mode); 169 } 170 171 function _fetch() 172 { 173 if ($this->_currentRow >= $this->_numOfRows && $this->_numOfRows >= 0) 174 return false; 175 176 $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode); 177 178 if ($this->fields) { 179 if (isset($this->_blobArr)) $this->_fixblobs(); 180 $this->_updatefields(); 181 } 182 183 return (is_array($this->fields)); 184 } 185 186 // Create associative array 187 function _updatefields() 188 { 189 if (ADODB_ASSOC_CASE == 2) return; // native 190 191 $arr = array(); 192 $lowercase = (ADODB_ASSOC_CASE == 0); 193 194 foreach($this->fields as $k => $v) { 195 if (is_integer($k)) $arr[$k] = $v; 196 else { 197 if ($lowercase) 198 $arr[strtolower($k)] = $v; 199 else 200 $arr[strtoupper($k)] = $v; 201 } 202 } 203 $this->fields = $arr; 204 } 205 206 function MoveNext() 207 { 208 if (!$this->EOF) { 209 $this->_currentRow++; 210 if ($this->_numOfRows < 0 || $this->_numOfRows > $this->_currentRow) { 211 $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode); 212 213 if (is_array($this->fields)) { 214 if ($this->fields) { 215 if (isset($this->_blobArr)) $this->_fixblobs(); 216 217 $this->_updatefields(); 218 } 219 return true; 220 } 221 } 222 223 224 $this->fields = false; 225 $this->EOF = true; 226 } 227 return false; 228 } 229 } 230 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |