15 if (!defined(
'ADODB_DIR'))
die();
17 include_once(ADODB_DIR.
"/drivers/adodb-postgres64.inc.php");
28 WHEN x.sequence_name != '' THEN 'SERIAL' 31 a.attlen,a.atttypmod,a.attnotnull,a.atthasdef,a.attnum 32 FROM pg_class c, pg_attribute a 33 JOIN pg_type t ON a.atttypid = t.oid 35 (SELECT c.relname as sequence_name, 36 c1.relname as related_table, 37 a.attname as related_column 39 JOIN pg_depend d ON d.objid = c.oid 40 LEFT JOIN pg_class c1 ON d.refobjid = c1.oid 41 LEFT JOIN pg_attribute a ON (d.refobjid, d.refobjsubid) = (a.attrelid, a.attnum) 42 WHERE c.relkind = 'S' AND c1.relname = '%s') x 43 ON x.related_column= a.attname 44 WHERE c.relkind in ('r','v') AND 45 (c.relname='%s' or c.relname = lower('%s')) AND 46 a.attname not like '....%%' AND 55 WHEN x.sequence_name != '' THEN 'SERIAL' 58 a.attlen, a.atttypmod, a.attnotnull, a.atthasdef, a.attnum 59 FROM pg_class c, pg_namespace n, pg_attribute a 60 JOIN pg_type t ON a.atttypid = t.oid 62 (SELECT c.relname as sequence_name, 63 c1.relname as related_table, 64 a.attname as related_column 66 JOIN pg_depend d ON d.objid = c.oid 67 LEFT JOIN pg_class c1 ON d.refobjid = c1.oid 68 LEFT JOIN pg_attribute a ON (d.refobjid, d.refobjsubid) = (a.attrelid, a.attnum) 69 WHERE c.relkind = 'S' AND c1.relname = '%s') x 70 ON x.related_column= a.attname 71 WHERE c.relkind in ('r','v') AND (c.relname='%s' or c.relname = lower('%s')) 72 AND c.relnamespace=n.oid and n.nspname='%s' 73 AND a.attname not like '....%%' AND a.attnum > 0 74 AND a.atttypid = t.oid AND a.attrelid = c.oid 80 parent::__construct();
81 if (ADODB_ASSOC_CASE !== 2) {
82 $this->rsPrefix .=
'assoc_';
84 $this->_bindInputArray = PHP_VERSION >= 5.1;
92 $offsetStr = ($offset >= 0) ?
" OFFSET ".((integer)$offset) :
'';
93 $limitStr = ($nrows >= 0) ?
" LIMIT ".((integer)$nrows) :
'';
95 $rs = $this->CacheExecute($secs2cache,
$sql.
"$limitStr$offsetStr",$inputarr);
97 $rs = $this->Execute(
$sql.
"$limitStr$offsetStr",$inputarr);
121 SELECT fum.ftblname AS lookup_table, split_part(fum.rf, ')'::text, 1) AS lookup_field, 122 fum.ltable AS dep_table, split_part(fum.lf, ')'::text, 1) AS dep_field 124 SELECT fee.ltable, fee.ftblname, fee.consrc, split_part(fee.consrc,'('::text, 2) AS lf, 125 split_part(fee.consrc, '('::text, 3) AS rf 127 SELECT foo.relname AS ltable, foo.ftblname, 128 pg_get_constraintdef(foo.oid) AS consrc 130 SELECT c.oid, c.conname AS name, t.relname, ft.relname AS ftblname 132 JOIN pg_class t ON (t.oid = c.conrelid) 133 JOIN pg_class ft ON (ft.oid = c.confrelid) 134 JOIN pg_namespace nft ON (nft.oid = ft.relnamespace) 135 LEFT JOIN pg_description ds ON (ds.objoid = c.oid) 136 JOIN pg_namespace n ON (n.oid = t.relnamespace) 137 WHERE c.contype = 'f'::\"char\" 138 ORDER BY t.relname, n.nspname, c.conname, c.oid 141 WHERE fum.ltable='".strtolower($table).
"' 142 ORDER BY fum.ftblname, fum.ltable, split_part(fum.lf, ')'::text, 1) 146 if (!
$rs ||
$rs->EOF)
return false;
151 $a[strtoupper(
$rs->Fields(
'lookup_table'))][] = strtoupper(str_replace(
'"',
'',
$rs->Fields(
'dep_field').
'='.
$rs->Fields(
'lookup_field')));
153 $a[
$rs->Fields(
'lookup_table')][] = str_replace(
'"',
'',
$rs->Fields(
'dep_field').
'='.
$rs->Fields(
'lookup_field'));
165 $sql =
'SELECT t.tgargs as args 167 pg_trigger t,pg_class c,pg_proc p 170 t.tgrelid = c.oid AND 172 p.proname = \'RI_FKey_check_ins\' AND 173 c.relname = \''.strtolower($table).
'\' 177 $rs = $this->Execute($sql); 179 if (!$rs || $rs->EOF) return false; 181 $arr = $rs->GetArray(); 183 foreach($arr as $v) { 184 $data = explode(chr(0), $v['args
']); 185 $size = count($data)-1; //-1 because the last node is empty 186 for($i = 4; $i < $size; $i++) { 188 $a[strtoupper($data[2])][] = strtoupper($data[$i].'=
'.$data[++$i]); 190 $a[$data[2]][] = $data[$i].'=
'.$data[++$i]; 196 function _query($sql,$inputarr=false) 198 if (! $this->_bindInputArray) { 199 // We don't have native support
for parameterized queries, so let
's emulate it at the parent 200 return ADODB_postgres64::_query($sql, $inputarr); 204 $this->_errorMsg = false; 205 // -- added Cristiano da Cunha Duarte 207 $sqlarr = explode('?
',trim($sql)); 210 $last = sizeof($sqlarr)-1; 211 foreach($sqlarr as $v) { 212 if ($last < $i) $sql .= $v; 213 else $sql .= $v.' $
'.$i; 217 $rez = pg_query_params($this->_connectionID,$sql, $inputarr); 219 $rez = pg_query($this->_connectionID,$sql); 221 // check if no data returned, then no need to create real recordset 222 if ($rez && pg_numfields($rez) <= 0) { 223 if (is_resource($this->_resultid) && get_resource_type($this->_resultid) === 'pgsql result
') { 224 pg_freeresult($this->_resultid); 226 $this->_resultid = $rez; 232 // this is a set of functions for managing client encoding - very important if the encodings 233 // of your database and your output target (i.e. HTML) don't match
242 $this->charSet = @pg_client_encoding($this->_connectionID);
243 if (!$this->charSet) {
254 if ($this->charSet !== $charset_name) {
255 $if = pg_set_client_encoding($this->_connectionID, $charset_name);
256 if ($if ==
"0" & $this->
GetCharSet() == $charset_name) {
270 var $databaseType =
"postgres7";
275 parent::__construct($queryID, $mode);
282 $this->_currentRow++;
283 if ($this->_numOfRows < 0 || $this->_numOfRows > $this->_currentRow) {
284 $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode);
286 if (is_array($this->fields)) {
287 if ($this->fields && isset($this->_blobArr)) $this->_fixblobs();
291 $this->fields =
false;
301 var $databaseType =
"postgres7";
306 parent::__construct($queryID, $mode);
311 if ($this->_currentRow >= $this->_numOfRows && $this->_numOfRows >= 0)
314 $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode);
317 if (isset($this->_blobArr)) $this->_fixblobs();
318 $this->_updatefields();
321 return (is_array($this->fields));
327 if (ADODB_ASSOC_CASE == 2)
return;
330 $lowercase = (ADODB_ASSOC_CASE == 0);
332 foreach($this->fields as $k => $v) {
333 if (is_integer($k)) $arr[$k] = $v;
336 $arr[strtolower($k)] = $v;
338 $arr[strtoupper($k)] = $v;
341 $this->fields = $arr;
347 $this->_currentRow++;
348 if ($this->_numOfRows < 0 || $this->_numOfRows > $this->_currentRow) {
349 $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode);
351 if (is_array($this->fields)) {
353 if (isset($this->_blobArr)) $this->_fixblobs();
355 $this->_updatefields();
362 $this->fields =
false;
_old_MetaForeignKeys($table, $owner=false, $upper=false)
SetCharSet($charset_name)
if(isset($_REQUEST['nrows'])) else $rs
__construct($queryID, $mode=false)
MetaForeignKeys($table, $owner=false, $upper=false)
SelectLimit($sql, $nrows=-1, $offset=-1, $inputarr=false, $secs2cache=0)
__construct($queryID, $mode=false)