@@ -20,14 +20,14 @@ |
||
20 | 20 | include_once(ADODB_DIR.'/drivers/adodb-postgres64.inc.php'); |
21 | 21 | |
22 | 22 | class ADODB_netezza extends ADODB_postgres64 { |
23 | - var $databaseType = 'netezza'; |
|
23 | + var $databaseType = 'netezza'; |
|
24 | 24 | var $dataProvider = 'netezza'; |
25 | 25 | var $hasInsertID = false; |
26 | 26 | var $_resultid = false; |
27 | 27 | var $concat_operator='||'; |
28 | 28 | var $random = 'random'; |
29 | 29 | var $metaDatabasesSQL = "select objname from _v_object_data where objtype='database' order by 1"; |
30 | - var $metaTablesSQL = "select objname from _v_object_data where objtype='table' order by 1"; |
|
30 | + var $metaTablesSQL = "select objname from _v_object_data where objtype='table' order by 1"; |
|
31 | 31 | var $isoDates = true; // accepts dates in ISO format |
32 | 32 | var $sysDate = "CURRENT_DATE"; |
33 | 33 | var $sysTimeStamp = "CURRENT_TIMESTAMP"; |
@@ -327,29 +327,29 @@ discard block |
||
327 | 327 | |
328 | 328 | global $ADODB_FETCH_MODE; |
329 | 329 | $save = $ADODB_FETCH_MODE; |
330 | - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; |
|
331 | - if ($this->fetchMode !== FALSE) { |
|
332 | - $savem = $this->SetFetchMode(FALSE); |
|
333 | - } |
|
330 | + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; |
|
331 | + if ($this->fetchMode !== FALSE) { |
|
332 | + $savem = $this->SetFetchMode(FALSE); |
|
333 | + } |
|
334 | 334 | |
335 | - $rs = $this->Execute($sql); |
|
336 | - if (isset($savem)) { |
|
337 | - $this->SetFetchMode($savem); |
|
338 | - } |
|
339 | - $ADODB_FETCH_MODE = $save; |
|
335 | + $rs = $this->Execute($sql); |
|
336 | + if (isset($savem)) { |
|
337 | + $this->SetFetchMode($savem); |
|
338 | + } |
|
339 | + $ADODB_FETCH_MODE = $save; |
|
340 | 340 | |
341 | - if (!is_object($rs)) { |
|
342 | - return FALSE; |
|
343 | - } |
|
341 | + if (!is_object($rs)) { |
|
342 | + return FALSE; |
|
343 | + } |
|
344 | 344 | |
345 | 345 | $indexes = array(); |
346 | 346 | while ($row = $rs->FetchRow()) { |
347 | 347 | if (!$primary && $row[5]) continue; |
348 | 348 | |
349 | - $indexes[$row[0]]['unique'] = $row[6]; |
|
350 | - $indexes[$row[0]]['columns'][] = $row[1]; |
|
351 | - } |
|
352 | - return $indexes; |
|
349 | + $indexes[$row[0]]['unique'] = $row[6]; |
|
350 | + $indexes[$row[0]]['columns'][] = $row[1]; |
|
351 | + } |
|
352 | + return $indexes; |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | function MetaForeignKeys($table, $owner=false, $upper=false) |
@@ -536,28 +536,28 @@ discard block |
||
536 | 536 | } |
537 | 537 | |
538 | 538 | // returns concatenated string |
539 | - // MSSQL requires integers to be cast as strings |
|
540 | - // automatically cast every datatype to VARCHAR(255) |
|
541 | - // @author David Rogers (introspectshun) |
|
542 | - function Concat() |
|
543 | - { |
|
544 | - $s = ""; |
|
545 | - $arr = func_get_args(); |
|
546 | - |
|
547 | - // Split single record on commas, if possible |
|
548 | - if (sizeof($arr) == 1) { |
|
549 | - foreach ($arr as $arg) { |
|
550 | - $args = explode(',', $arg); |
|
551 | - } |
|
552 | - $arr = $args; |
|
553 | - } |
|
554 | - |
|
555 | - array_walk($arr, create_function('&$v', '$v = "CAST(" . $v . " AS VARCHAR(255))";')); |
|
556 | - $s = implode('+',$arr); |
|
557 | - if (sizeof($arr) > 0) return "$s"; |
|
539 | + // MSSQL requires integers to be cast as strings |
|
540 | + // automatically cast every datatype to VARCHAR(255) |
|
541 | + // @author David Rogers (introspectshun) |
|
542 | + function Concat() |
|
543 | + { |
|
544 | + $s = ""; |
|
545 | + $arr = func_get_args(); |
|
546 | + |
|
547 | + // Split single record on commas, if possible |
|
548 | + if (sizeof($arr) == 1) { |
|
549 | + foreach ($arr as $arg) { |
|
550 | + $args = explode(',', $arg); |
|
551 | + } |
|
552 | + $arr = $args; |
|
553 | + } |
|
554 | + |
|
555 | + array_walk($arr, create_function('&$v', '$v = "CAST(" . $v . " AS VARCHAR(255))";')); |
|
556 | + $s = implode('+',$arr); |
|
557 | + if (sizeof($arr) > 0) return "$s"; |
|
558 | 558 | |
559 | 559 | return ''; |
560 | - } |
|
560 | + } |
|
561 | 561 | |
562 | 562 | /* |
563 | 563 | Usage: |
@@ -185,84 +185,84 @@ |
||
185 | 185 | |
186 | 186 | |
187 | 187 | # Added 2003-10-05 by Chris Phillipson |
188 | - # Used ASA SQL Reference Manual -- http://sybooks.sybase.com/onlinebooks/group-aw/awg0800e/dbrfen8/@ebt-link;pt=16756?target=%25N%15_12018_START_RESTART_N%25 |
|
189 | - # to convert similar Microsoft SQL*Server (mssql) API into Sybase compatible version |
|
190 | - // Format date column in sql string given an input format that understands Y M D |
|
191 | - function SQLDate($fmt, $col=false) |
|
192 | - { |
|
193 | - if (!$col) $col = $this->sysTimeStamp; |
|
194 | - $s = ''; |
|
188 | + # Used ASA SQL Reference Manual -- http://sybooks.sybase.com/onlinebooks/group-aw/awg0800e/dbrfen8/@ebt-link;pt=16756?target=%25N%15_12018_START_RESTART_N%25 |
|
189 | + # to convert similar Microsoft SQL*Server (mssql) API into Sybase compatible version |
|
190 | + // Format date column in sql string given an input format that understands Y M D |
|
191 | + function SQLDate($fmt, $col=false) |
|
192 | + { |
|
193 | + if (!$col) $col = $this->sysTimeStamp; |
|
194 | + $s = ''; |
|
195 | 195 | |
196 | - $len = strlen($fmt); |
|
197 | - for ($i=0; $i < $len; $i++) { |
|
198 | - if ($s) $s .= '+'; |
|
199 | - $ch = $fmt[$i]; |
|
200 | - switch($ch) { |
|
201 | - case 'Y': |
|
202 | - case 'y': |
|
203 | - $s .= "datename(yy,$col)"; |
|
204 | - break; |
|
205 | - case 'M': |
|
206 | - $s .= "convert(char(3),$col,0)"; |
|
207 | - break; |
|
208 | - case 'm': |
|
209 | - $s .= "replace(str(month($col),2),' ','0')"; |
|
210 | - break; |
|
211 | - case 'Q': |
|
212 | - case 'q': |
|
213 | - $s .= "datename(qq,$col)"; |
|
214 | - break; |
|
215 | - case 'D': |
|
216 | - case 'd': |
|
217 | - $s .= "replace(str(datepart(dd,$col),2),' ','0')"; |
|
218 | - break; |
|
219 | - case 'h': |
|
220 | - $s .= "substring(convert(char(14),$col,0),13,2)"; |
|
221 | - break; |
|
196 | + $len = strlen($fmt); |
|
197 | + for ($i=0; $i < $len; $i++) { |
|
198 | + if ($s) $s .= '+'; |
|
199 | + $ch = $fmt[$i]; |
|
200 | + switch($ch) { |
|
201 | + case 'Y': |
|
202 | + case 'y': |
|
203 | + $s .= "datename(yy,$col)"; |
|
204 | + break; |
|
205 | + case 'M': |
|
206 | + $s .= "convert(char(3),$col,0)"; |
|
207 | + break; |
|
208 | + case 'm': |
|
209 | + $s .= "replace(str(month($col),2),' ','0')"; |
|
210 | + break; |
|
211 | + case 'Q': |
|
212 | + case 'q': |
|
213 | + $s .= "datename(qq,$col)"; |
|
214 | + break; |
|
215 | + case 'D': |
|
216 | + case 'd': |
|
217 | + $s .= "replace(str(datepart(dd,$col),2),' ','0')"; |
|
218 | + break; |
|
219 | + case 'h': |
|
220 | + $s .= "substring(convert(char(14),$col,0),13,2)"; |
|
221 | + break; |
|
222 | 222 | |
223 | - case 'H': |
|
224 | - $s .= "replace(str(datepart(hh,$col),2),' ','0')"; |
|
225 | - break; |
|
223 | + case 'H': |
|
224 | + $s .= "replace(str(datepart(hh,$col),2),' ','0')"; |
|
225 | + break; |
|
226 | 226 | |
227 | - case 'i': |
|
228 | - $s .= "replace(str(datepart(mi,$col),2),' ','0')"; |
|
229 | - break; |
|
230 | - case 's': |
|
231 | - $s .= "replace(str(datepart(ss,$col),2),' ','0')"; |
|
232 | - break; |
|
233 | - case 'a': |
|
234 | - case 'A': |
|
235 | - $s .= "substring(convert(char(19),$col,0),18,2)"; |
|
236 | - break; |
|
227 | + case 'i': |
|
228 | + $s .= "replace(str(datepart(mi,$col),2),' ','0')"; |
|
229 | + break; |
|
230 | + case 's': |
|
231 | + $s .= "replace(str(datepart(ss,$col),2),' ','0')"; |
|
232 | + break; |
|
233 | + case 'a': |
|
234 | + case 'A': |
|
235 | + $s .= "substring(convert(char(19),$col,0),18,2)"; |
|
236 | + break; |
|
237 | 237 | |
238 | - default: |
|
239 | - if ($ch == '\\') { |
|
240 | - $i++; |
|
241 | - $ch = substr($fmt,$i,1); |
|
242 | - } |
|
243 | - $s .= $this->qstr($ch); |
|
244 | - break; |
|
245 | - } |
|
246 | - } |
|
247 | - return $s; |
|
248 | - } |
|
238 | + default: |
|
239 | + if ($ch == '\\') { |
|
240 | + $i++; |
|
241 | + $ch = substr($fmt,$i,1); |
|
242 | + } |
|
243 | + $s .= $this->qstr($ch); |
|
244 | + break; |
|
245 | + } |
|
246 | + } |
|
247 | + return $s; |
|
248 | + } |
|
249 | 249 | |
250 | 250 | # Added 2003-10-07 by Chris Phillipson |
251 | - # Used ASA SQL Reference Manual -- http://sybooks.sybase.com/onlinebooks/group-aw/awg0800e/dbrfen8/@ebt-link;pt=5981;uf=0?target=0;window=new;showtoc=true;book=dbrfen8 |
|
252 | - # to convert similar Microsoft SQL*Server (mssql) API into Sybase compatible version |
|
253 | - function MetaPrimaryKeys($table) |
|
254 | - { |
|
255 | - $sql = "SELECT c.column_name " . |
|
256 | - "FROM syscolumn c, systable t " . |
|
257 | - "WHERE t.table_name='$table' AND c.table_id=t.table_id " . |
|
258 | - "AND t.table_type='BASE' " . |
|
259 | - "AND c.pkey = 'Y' " . |
|
260 | - "ORDER BY c.column_id"; |
|
251 | + # Used ASA SQL Reference Manual -- http://sybooks.sybase.com/onlinebooks/group-aw/awg0800e/dbrfen8/@ebt-link;pt=5981;uf=0?target=0;window=new;showtoc=true;book=dbrfen8 |
|
252 | + # to convert similar Microsoft SQL*Server (mssql) API into Sybase compatible version |
|
253 | + function MetaPrimaryKeys($table) |
|
254 | + { |
|
255 | + $sql = "SELECT c.column_name " . |
|
256 | + "FROM syscolumn c, systable t " . |
|
257 | + "WHERE t.table_name='$table' AND c.table_id=t.table_id " . |
|
258 | + "AND t.table_type='BASE' " . |
|
259 | + "AND c.pkey = 'Y' " . |
|
260 | + "ORDER BY c.column_id"; |
|
261 | 261 | |
262 | - $a = $this->GetCol($sql); |
|
263 | - if ($a && sizeof($a)>0) return $a; |
|
264 | - return false; |
|
265 | - } |
|
262 | + $a = $this->GetCol($sql); |
|
263 | + if ($a && sizeof($a)>0) return $a; |
|
264 | + return false; |
|
265 | + } |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /*-------------------------------------------------------------------------------------- |
@@ -63,43 +63,43 @@ discard block |
||
63 | 63 | |
64 | 64 | global $ADODB_FETCH_MODE; |
65 | 65 | $save = $ADODB_FETCH_MODE; |
66 | - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; |
|
67 | - if ($this->fetchMode !== FALSE) { |
|
68 | - $savem = $this->SetFetchMode(FALSE); |
|
69 | - } |
|
66 | + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; |
|
67 | + if ($this->fetchMode !== FALSE) { |
|
68 | + $savem = $this->SetFetchMode(FALSE); |
|
69 | + } |
|
70 | 70 | |
71 | - $rs = $this->Execute($sql); |
|
72 | - if (isset($savem)) { |
|
73 | - $this->SetFetchMode($savem); |
|
74 | - } |
|
75 | - $ADODB_FETCH_MODE = $save; |
|
71 | + $rs = $this->Execute($sql); |
|
72 | + if (isset($savem)) { |
|
73 | + $this->SetFetchMode($savem); |
|
74 | + } |
|
75 | + $ADODB_FETCH_MODE = $save; |
|
76 | 76 | |
77 | - if (!is_object($rs)) { |
|
78 | - return FALSE; |
|
79 | - } |
|
77 | + if (!is_object($rs)) { |
|
78 | + return FALSE; |
|
79 | + } |
|
80 | 80 | |
81 | 81 | $indexes = array(); |
82 | 82 | while ($row = $rs->FetchRow()) { |
83 | - $indexes[$row[0]]['unique'] = $row[1] == 'UNIQUE'; |
|
84 | - $indexes[$row[0]]['columns'][] = $row[2]; |
|
85 | - } |
|
83 | + $indexes[$row[0]]['unique'] = $row[1] == 'UNIQUE'; |
|
84 | + $indexes[$row[0]]['columns'][] = $row[2]; |
|
85 | + } |
|
86 | 86 | if ($primary) { |
87 | 87 | $indexes['SYSPRIMARYKEYINDEX'] = array( |
88 | 88 | 'unique' => True, // by definition |
89 | 89 | 'columns' => $this->GetCol("SELECT columnname FROM COLUMNS WHERE tablename=$table AND mode='KEY' ORDER BY pos"), |
90 | 90 | ); |
91 | 91 | } |
92 | - return $indexes; |
|
92 | + return $indexes; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | function &MetaColumns ($table) |
96 | 96 | { |
97 | 97 | global $ADODB_FETCH_MODE; |
98 | 98 | $save = $ADODB_FETCH_MODE; |
99 | - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; |
|
100 | - if ($this->fetchMode !== FALSE) { |
|
101 | - $savem = $this->SetFetchMode(FALSE); |
|
102 | - } |
|
99 | + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; |
|
100 | + if ($this->fetchMode !== FALSE) { |
|
101 | + $savem = $this->SetFetchMode(FALSE); |
|
102 | + } |
|
103 | 103 | $table = $this->Quote(strtoupper($table)); |
104 | 104 | |
105 | 105 | $retarr = array(); |
@@ -132,10 +132,10 @@ discard block |
||
132 | 132 | } |
133 | 133 | $retarr[$fld->name] = $fld; |
134 | 134 | } |
135 | - if (isset($savem)) { |
|
136 | - $this->SetFetchMode($savem); |
|
137 | - } |
|
138 | - $ADODB_FETCH_MODE = $save; |
|
135 | + if (isset($savem)) { |
|
136 | + $this->SetFetchMode($savem); |
|
137 | + } |
|
138 | + $ADODB_FETCH_MODE = $save; |
|
139 | 139 | |
140 | 140 | return $retarr; |
141 | 141 | } |
@@ -76,55 +76,55 @@ discard block |
||
76 | 76 | |
77 | 77 | function &MetaIndexes ($table, $primary = FALSE, $owner=false) |
78 | 78 | { |
79 | - // save old fetch mode |
|
80 | - global $ADODB_FETCH_MODE; |
|
79 | + // save old fetch mode |
|
80 | + global $ADODB_FETCH_MODE; |
|
81 | 81 | |
82 | 82 | $false = false; |
83 | - $save = $ADODB_FETCH_MODE; |
|
84 | - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; |
|
85 | - if ($this->fetchMode !== FALSE) { |
|
86 | - $savem = $this->SetFetchMode(FALSE); |
|
87 | - } |
|
83 | + $save = $ADODB_FETCH_MODE; |
|
84 | + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; |
|
85 | + if ($this->fetchMode !== FALSE) { |
|
86 | + $savem = $this->SetFetchMode(FALSE); |
|
87 | + } |
|
88 | 88 | |
89 | - // get index details |
|
90 | - $rs = $this->Execute(sprintf('SHOW INDEX FROM %s',$table)); |
|
89 | + // get index details |
|
90 | + $rs = $this->Execute(sprintf('SHOW INDEX FROM %s',$table)); |
|
91 | 91 | |
92 | - // restore fetchmode |
|
93 | - if (isset($savem)) { |
|
94 | - $this->SetFetchMode($savem); |
|
95 | - } |
|
96 | - $ADODB_FETCH_MODE = $save; |
|
92 | + // restore fetchmode |
|
93 | + if (isset($savem)) { |
|
94 | + $this->SetFetchMode($savem); |
|
95 | + } |
|
96 | + $ADODB_FETCH_MODE = $save; |
|
97 | 97 | |
98 | - if (!is_object($rs)) { |
|
99 | - return $false; |
|
100 | - } |
|
98 | + if (!is_object($rs)) { |
|
99 | + return $false; |
|
100 | + } |
|
101 | 101 | |
102 | - $indexes = array (); |
|
102 | + $indexes = array (); |
|
103 | 103 | |
104 | - // parse index data into array |
|
105 | - while ($row = $rs->FetchRow()) { |
|
106 | - if ($primary == FALSE AND $row[2] == 'PRIMARY') { |
|
107 | - continue; |
|
108 | - } |
|
104 | + // parse index data into array |
|
105 | + while ($row = $rs->FetchRow()) { |
|
106 | + if ($primary == FALSE AND $row[2] == 'PRIMARY') { |
|
107 | + continue; |
|
108 | + } |
|
109 | 109 | |
110 | - if (!isset($indexes[$row[2]])) { |
|
111 | - $indexes[$row[2]] = array( |
|
112 | - 'unique' => ($row[1] == 0), |
|
113 | - 'columns' => array() |
|
114 | - ); |
|
115 | - } |
|
110 | + if (!isset($indexes[$row[2]])) { |
|
111 | + $indexes[$row[2]] = array( |
|
112 | + 'unique' => ($row[1] == 0), |
|
113 | + 'columns' => array() |
|
114 | + ); |
|
115 | + } |
|
116 | 116 | |
117 | - $indexes[$row[2]]['columns'][$row[3] - 1] = $row[4]. |
|
118 | - (is_numeric($row[7]) ? '('.(int)$row[7].')' : ''); |
|
119 | - } |
|
117 | + $indexes[$row[2]]['columns'][$row[3] - 1] = $row[4]. |
|
118 | + (is_numeric($row[7]) ? '('.(int)$row[7].')' : ''); |
|
119 | + } |
|
120 | 120 | |
121 | - // sort columns by order in the index |
|
122 | - foreach ( array_keys ($indexes) as $index ) |
|
123 | - { |
|
124 | - ksort ($indexes[$index]['columns']); |
|
125 | - } |
|
121 | + // sort columns by order in the index |
|
122 | + foreach ( array_keys ($indexes) as $index ) |
|
123 | + { |
|
124 | + ksort ($indexes[$index]['columns']); |
|
125 | + } |
|
126 | 126 | |
127 | - return $indexes; |
|
127 | + return $indexes; |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | |
@@ -546,43 +546,43 @@ discard block |
||
546 | 546 | |
547 | 547 | // "Innox - Juan Carlos Gonzalez" <jgonzalez#innox.com.mx> |
548 | 548 | function MetaForeignKeys( $table, $owner = FALSE, $upper = FALSE, $asociative = FALSE ) |
549 | - { |
|
550 | - if ( !empty($owner) ) { |
|
551 | - $table = "$owner.$table"; |
|
552 | - } |
|
553 | - $a_create_table = $this->getRow(sprintf('SHOW CREATE TABLE %s', $table)); |
|
554 | - $create_sql = $a_create_table[1]; |
|
555 | - |
|
556 | - $matches = array(); |
|
557 | - $foreign_keys = array(); |
|
558 | - if ( preg_match_all("/FOREIGN KEY \(`(.*?)`\) REFERENCES `(.*?)` \(`(.*?)`\)/", $create_sql, $matches) ) { |
|
559 | - $num_keys = count($matches[0]); |
|
560 | - for ( $i = 0; $i < $num_keys; $i ++ ) { |
|
561 | - $my_field = explode('`, `', $matches[1][$i]); |
|
562 | - $ref_table = $matches[2][$i]; |
|
563 | - $ref_field = explode('`, `', $matches[3][$i]); |
|
564 | - |
|
565 | - if ( $upper ) { |
|
566 | - $ref_table = strtoupper($ref_table); |
|
567 | - } |
|
568 | - |
|
569 | - $foreign_keys[$ref_table] = array(); |
|
570 | - $num_fields = count($my_field); |
|
571 | - for ( $j = 0; $j < $num_fields; $j ++ ) { |
|
572 | - if ( $asociative ) { |
|
573 | - $foreign_keys[$ref_table][$ref_field[$j]] = $my_field[$j]; |
|
574 | - } else { |
|
575 | - $foreign_keys[$ref_table][] = "{$my_field[$j]}={$ref_field[$j]}"; |
|
576 | - } |
|
577 | - } |
|
578 | - } |
|
579 | - } |
|
580 | - return $foreign_keys; |
|
581 | - } |
|
549 | + { |
|
550 | + if ( !empty($owner) ) { |
|
551 | + $table = "$owner.$table"; |
|
552 | + } |
|
553 | + $a_create_table = $this->getRow(sprintf('SHOW CREATE TABLE %s', $table)); |
|
554 | + $create_sql = $a_create_table[1]; |
|
555 | + |
|
556 | + $matches = array(); |
|
557 | + $foreign_keys = array(); |
|
558 | + if ( preg_match_all("/FOREIGN KEY \(`(.*?)`\) REFERENCES `(.*?)` \(`(.*?)`\)/", $create_sql, $matches) ) { |
|
559 | + $num_keys = count($matches[0]); |
|
560 | + for ( $i = 0; $i < $num_keys; $i ++ ) { |
|
561 | + $my_field = explode('`, `', $matches[1][$i]); |
|
562 | + $ref_table = $matches[2][$i]; |
|
563 | + $ref_field = explode('`, `', $matches[3][$i]); |
|
564 | + |
|
565 | + if ( $upper ) { |
|
566 | + $ref_table = strtoupper($ref_table); |
|
567 | + } |
|
568 | + |
|
569 | + $foreign_keys[$ref_table] = array(); |
|
570 | + $num_fields = count($my_field); |
|
571 | + for ( $j = 0; $j < $num_fields; $j ++ ) { |
|
572 | + if ( $asociative ) { |
|
573 | + $foreign_keys[$ref_table][$ref_field[$j]] = $my_field[$j]; |
|
574 | + } else { |
|
575 | + $foreign_keys[$ref_table][] = "{$my_field[$j]}={$ref_field[$j]}"; |
|
576 | + } |
|
577 | + } |
|
578 | + } |
|
579 | + } |
|
580 | + return $foreign_keys; |
|
581 | + } |
|
582 | 582 | |
583 | 583 | /** |
584 | - * @var array $charset2mysql translate www charsets to mysql ones |
|
585 | - */ |
|
584 | + * @var array $charset2mysql translate www charsets to mysql ones |
|
585 | + */ |
|
586 | 586 | var $charset2mysql = array( |
587 | 587 | 'utf-8' => 'utf8', |
588 | 588 | 'iso-8859-1' => 'latin1', |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | $fld->scale = $rs->fields[3]; |
121 | 121 | if ($rs->fields[1] == 'NUMBER' && $rs->fields[3] == 0) { |
122 | 122 | $fld->type ='INT'; |
123 | - $fld->max_length = $rs->fields[4]; |
|
124 | - } |
|
123 | + $fld->max_length = $rs->fields[4]; |
|
124 | + } |
|
125 | 125 | $fld->not_null = (strncmp($rs->fields[5], 'NOT',3) === 0); |
126 | 126 | $fld->binary = (strpos($fld->type,'BLOB') !== false); |
127 | 127 | $fld->default_value = $rs->fields[6]; |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | if (!function_exists('OCIPLogon')) return null; |
185 | 185 | |
186 | 186 | |
187 | - $this->_errorMsg = false; |
|
187 | + $this->_errorMsg = false; |
|
188 | 188 | $this->_errorCode = false; |
189 | 189 | |
190 | 190 | if($argHostname) { // added by Jorma Tuomainen <[email protected]> |
@@ -311,15 +311,15 @@ discard block |
||
311 | 311 | // Mark Newnham |
312 | 312 | function &MetaIndexes ($table, $primary = FALSE, $owner=false) |
313 | 313 | { |
314 | - // save old fetch mode |
|
315 | - global $ADODB_FETCH_MODE; |
|
314 | + // save old fetch mode |
|
315 | + global $ADODB_FETCH_MODE; |
|
316 | 316 | |
317 | - $save = $ADODB_FETCH_MODE; |
|
318 | - $ADODB_FETCH_MODE = ADODB_FETCH_NUM; |
|
317 | + $save = $ADODB_FETCH_MODE; |
|
318 | + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; |
|
319 | 319 | |
320 | - if ($this->fetchMode !== FALSE) { |
|
321 | - $savem = $this->SetFetchMode(FALSE); |
|
322 | - } |
|
320 | + if ($this->fetchMode !== FALSE) { |
|
321 | + $savem = $this->SetFetchMode(FALSE); |
|
322 | + } |
|
323 | 323 | |
324 | 324 | // get index details |
325 | 325 | $table = strtoupper($table); |
@@ -334,45 +334,45 @@ discard block |
||
334 | 334 | |
335 | 335 | if ($primary==TRUE && $primary_key=='') { |
336 | 336 | if (isset($savem)) |
337 | - $this->SetFetchMode($savem); |
|
337 | + $this->SetFetchMode($savem); |
|
338 | 338 | $ADODB_FETCH_MODE = $save; |
339 | 339 | return $false; //There is no primary key |
340 | 340 | } |
341 | 341 | |
342 | - $rs = $this->Execute(sprintf("SELECT ALL_INDEXES.INDEX_NAME, ALL_INDEXES.UNIQUENESS, ALL_IND_COLUMNS.COLUMN_POSITION, ALL_IND_COLUMNS.COLUMN_NAME FROM ALL_INDEXES,ALL_IND_COLUMNS WHERE UPPER(ALL_INDEXES.TABLE_NAME)='%s' AND ALL_IND_COLUMNS.INDEX_NAME=ALL_INDEXES.INDEX_NAME",$table)); |
|
342 | + $rs = $this->Execute(sprintf("SELECT ALL_INDEXES.INDEX_NAME, ALL_INDEXES.UNIQUENESS, ALL_IND_COLUMNS.COLUMN_POSITION, ALL_IND_COLUMNS.COLUMN_NAME FROM ALL_INDEXES,ALL_IND_COLUMNS WHERE UPPER(ALL_INDEXES.TABLE_NAME)='%s' AND ALL_IND_COLUMNS.INDEX_NAME=ALL_INDEXES.INDEX_NAME",$table)); |
|
343 | 343 | |
344 | 344 | |
345 | - if (!is_object($rs)) { |
|
345 | + if (!is_object($rs)) { |
|
346 | 346 | if (isset($savem)) |
347 | 347 | $this->SetFetchMode($savem); |
348 | 348 | $ADODB_FETCH_MODE = $save; |
349 | - return $false; |
|
350 | - } |
|
349 | + return $false; |
|
350 | + } |
|
351 | 351 | |
352 | 352 | $indexes = array (); |
353 | - // parse index data into array |
|
353 | + // parse index data into array |
|
354 | 354 | |
355 | - while ($row = $rs->FetchRow()) { |
|
355 | + while ($row = $rs->FetchRow()) { |
|
356 | 356 | if ($primary && $row[0] != $primary_key) continue; |
357 | - if (!isset($indexes[$row[0]])) { |
|
357 | + if (!isset($indexes[$row[0]])) { |
|
358 | 358 | $indexes[$row[0]] = array( |
359 | 359 | 'unique' => ($row[1] == 'UNIQUE'), |
360 | 360 | 'columns' => array() |
361 | 361 | ); |
362 | - } |
|
363 | - $indexes[$row[0]]['columns'][$row[2] - 1] = $row[3]; |
|
364 | - } |
|
362 | + } |
|
363 | + $indexes[$row[0]]['columns'][$row[2] - 1] = $row[3]; |
|
364 | + } |
|
365 | 365 | |
366 | - // sort columns by order in the index |
|
367 | - foreach ( array_keys ($indexes) as $index ) { |
|
368 | - ksort ($indexes[$index]['columns']); |
|
369 | - } |
|
366 | + // sort columns by order in the index |
|
367 | + foreach ( array_keys ($indexes) as $index ) { |
|
368 | + ksort ($indexes[$index]['columns']); |
|
369 | + } |
|
370 | 370 | |
371 | 371 | if (isset($savem)) { |
372 | - $this->SetFetchMode($savem); |
|
372 | + $this->SetFetchMode($savem); |
|
373 | 373 | $ADODB_FETCH_MODE = $save; |
374 | 374 | } |
375 | - return $indexes; |
|
375 | + return $indexes; |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | function BeginTrans() |
@@ -630,24 +630,24 @@ discard block |
||
630 | 630 | } |
631 | 631 | |
632 | 632 | /** |
633 | - * Usage: |
|
634 | - * Store BLOBs and CLOBs |
|
635 | - * |
|
636 | - * Example: to store $var in a blob |
|
637 | - * |
|
638 | - * $conn->Execute('insert into TABLE (id,ablob) values(12,empty_blob())'); |
|
639 | - * $conn->UpdateBlob('TABLE', 'ablob', $varHoldingBlob, 'ID=12', 'BLOB'); |
|
640 | - * |
|
641 | - * $blobtype supports 'BLOB' and 'CLOB', but you need to change to 'empty_clob()'. |
|
642 | - * |
|
643 | - * to get length of LOB: |
|
644 | - * select DBMS_LOB.GETLENGTH(ablob) from TABLE |
|
645 | - * |
|
646 | - * If you are using CURSOR_SHARING = force, it appears this will case a segfault |
|
647 | - * under oracle 8.1.7.0. Run: |
|
648 | - * $db->Execute('ALTER SESSION SET CURSOR_SHARING=EXACT'); |
|
649 | - * before UpdateBlob() then... |
|
650 | - */ |
|
633 | + * Usage: |
|
634 | + * Store BLOBs and CLOBs |
|
635 | + * |
|
636 | + * Example: to store $var in a blob |
|
637 | + * |
|
638 | + * $conn->Execute('insert into TABLE (id,ablob) values(12,empty_blob())'); |
|
639 | + * $conn->UpdateBlob('TABLE', 'ablob', $varHoldingBlob, 'ID=12', 'BLOB'); |
|
640 | + * |
|
641 | + * $blobtype supports 'BLOB' and 'CLOB', but you need to change to 'empty_clob()'. |
|
642 | + * |
|
643 | + * to get length of LOB: |
|
644 | + * select DBMS_LOB.GETLENGTH(ablob) from TABLE |
|
645 | + * |
|
646 | + * If you are using CURSOR_SHARING = force, it appears this will case a segfault |
|
647 | + * under oracle 8.1.7.0. Run: |
|
648 | + * $db->Execute('ALTER SESSION SET CURSOR_SHARING=EXACT'); |
|
649 | + * before UpdateBlob() then... |
|
650 | + */ |
|
651 | 651 | |
652 | 652 | function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB') |
653 | 653 | { |
@@ -681,8 +681,8 @@ discard block |
||
681 | 681 | } |
682 | 682 | |
683 | 683 | /** |
684 | - * Usage: store file pointed to by $var in a blob |
|
685 | - */ |
|
684 | + * Usage: store file pointed to by $var in a blob |
|
685 | + */ |
|
686 | 686 | function UpdateBlobFile($table,$column,$val,$where,$blobtype='BLOB') |
687 | 687 | { |
688 | 688 | switch(strtoupper($blobtype)) { |
@@ -710,12 +710,12 @@ discard block |
||
710 | 710 | } |
711 | 711 | |
712 | 712 | /** |
713 | - * Execute SQL |
|
714 | - * |
|
715 | - * @param sql SQL statement to execute, or possibly an array holding prepared statement ($sql[0] will hold sql text) |
|
716 | - * @param [inputarr] holds the input data to bind to. Null elements will be set to null. |
|
717 | - * @return RecordSet or false |
|
718 | - */ |
|
713 | + * Execute SQL |
|
714 | + * |
|
715 | + * @param sql SQL statement to execute, or possibly an array holding prepared statement ($sql[0] will hold sql text) |
|
716 | + * @param [inputarr] holds the input data to bind to. Null elements will be set to null. |
|
717 | + * @return RecordSet or false |
|
718 | + */ |
|
719 | 719 | function &Execute($sql,$inputarr=false) |
720 | 720 | { |
721 | 721 | if ($this->fnExecute) { |
@@ -843,9 +843,9 @@ discard block |
||
843 | 843 | |
844 | 844 | if (!is_array($stmt)) return false; |
845 | 845 | |
846 | - if (($type == OCI_B_CURSOR) && sizeof($stmt) >= 5) { |
|
847 | - return OCIBindByName($stmt[1],":".$name,$stmt[4],$size,$type); |
|
848 | - } |
|
846 | + if (($type == OCI_B_CURSOR) && sizeof($stmt) >= 5) { |
|
847 | + return OCIBindByName($stmt[1],":".$name,$stmt[4],$size,$type); |
|
848 | + } |
|
849 | 849 | |
850 | 850 | if ($name == false) { |
851 | 851 | if ($type !== false) $rez = OCIBindByName($stmt[1],":".$stmt[2],$var,$size,$type); |
@@ -855,13 +855,13 @@ discard block |
||
855 | 855 | if ($this->debug) { |
856 | 856 | ADOConnection::outp("<b>Bind</b>: name = $name"); |
857 | 857 | } |
858 | - //we have to create a new Descriptor here |
|
858 | + //we have to create a new Descriptor here |
|
859 | 859 | $numlob = count($this->_refLOBs); |
860 | - $this->_refLOBs[$numlob]['LOB'] = OCINewDescriptor($this->_connectionID, oci_lob_desc($type)); |
|
860 | + $this->_refLOBs[$numlob]['LOB'] = OCINewDescriptor($this->_connectionID, oci_lob_desc($type)); |
|
861 | 861 | $this->_refLOBs[$numlob]['TYPE'] = $isOutput; |
862 | 862 | |
863 | 863 | $tmp = &$this->_refLOBs[$numlob]['LOB']; |
864 | - $rez = OCIBindByName($stmt[1], ":".$name, $tmp, -1, $type); |
|
864 | + $rez = OCIBindByName($stmt[1], ":".$name, $tmp, -1, $type); |
|
865 | 865 | if ($this->debug) { |
866 | 866 | ADOConnection::outp("<b>Bind</b>: descriptor has been allocated, var (".$name.") binded"); |
867 | 867 | } |
@@ -987,7 +987,7 @@ discard block |
||
987 | 987 | } |
988 | 988 | } |
989 | 989 | |
990 | - $this->_errorMsg = false; |
|
990 | + $this->_errorMsg = false; |
|
991 | 991 | $this->_errorCode = false; |
992 | 992 | if (OCIExecute($stmt,$this->_commit)) { |
993 | 993 | //OCIInternalDebug(1); |
@@ -1002,41 +1002,41 @@ discard block |
||
1002 | 1002 | //$_GLOBALS[$this -> _refLOBs[$key]['VAR']] = $tmp; |
1003 | 1003 | $this -> _refLOBs[$key]['VAR'] = $tmp; |
1004 | 1004 | } else { |
1005 | - $this->_refLOBs[$key]['LOB']->save($this->_refLOBs[$key]['VAR']); |
|
1005 | + $this->_refLOBs[$key]['LOB']->save($this->_refLOBs[$key]['VAR']); |
|
1006 | 1006 | $this -> _refLOBs[$key]['LOB']->free(); |
1007 | 1007 | unset($this -> _refLOBs[$key]); |
1008 | - if ($this->debug) { |
|
1008 | + if ($this->debug) { |
|
1009 | 1009 | ADOConnection::outp("<b>IN LOB</b>: LOB has been saved. <br>"); |
1010 | 1010 | } |
1011 | - } |
|
1011 | + } |
|
1012 | 1012 | } |
1013 | 1013 | } |
1014 | 1014 | |
1015 | - switch (@OCIStatementType($stmt)) { |
|
1016 | - case "SELECT": |
|
1015 | + switch (@OCIStatementType($stmt)) { |
|
1016 | + case "SELECT": |
|
1017 | 1017 | return $stmt; |
1018 | 1018 | |
1019 | 1019 | case 'DECLARE': |
1020 | - case "BEGIN": |
|
1021 | - if (is_array($sql) && !empty($sql[4])) { |
|
1020 | + case "BEGIN": |
|
1021 | + if (is_array($sql) && !empty($sql[4])) { |
|
1022 | 1022 | $cursor = $sql[4]; |
1023 | 1023 | if (is_resource($cursor)) { |
1024 | 1024 | $ok = OCIExecute($cursor); |
1025 | - return $cursor; |
|
1025 | + return $cursor; |
|
1026 | 1026 | } |
1027 | 1027 | return $stmt; |
1028 | - } else { |
|
1028 | + } else { |
|
1029 | 1029 | if (is_resource($stmt)) { |
1030 | 1030 | OCIFreeStatement($stmt); |
1031 | 1031 | return true; |
1032 | 1032 | } |
1033 | - return $stmt; |
|
1034 | - } |
|
1035 | - break; |
|
1036 | - default : |
|
1033 | + return $stmt; |
|
1034 | + } |
|
1035 | + break; |
|
1036 | + default : |
|
1037 | 1037 | // ociclose -- no because it could be used in a LOB? |
1038 | - return true; |
|
1039 | - } |
|
1038 | + return true; |
|
1039 | + } |
|
1040 | 1040 | } |
1041 | 1041 | return false; |
1042 | 1042 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | class ADODB_pdo_pgsql extends ADODB_pdo { |
13 | 13 | var $metaDatabasesSQL = "select datname from pg_database where datname not in ('template0','template1') order by 1"; |
14 | - var $metaTablesSQL = "select tablename,'T' from pg_tables where tablename not like 'pg\_%' |
|
14 | + var $metaTablesSQL = "select tablename,'T' from pg_tables where tablename not like 'pg\_%' |
|
15 | 15 | and tablename not in ('sql_features', 'sql_implementation_info', 'sql_languages', |
16 | 16 | 'sql_packages', 'sql_sizing', 'sql_sizing_profiles') |
17 | 17 | union |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | { |
84 | 84 | $info = $this->ServerInfo(); |
85 | 85 | if ($info['version'] >= 7.3) { |
86 | - $this->metaTablesSQL = "select tablename,'T' from pg_tables where tablename not like 'pg\_%' |
|
86 | + $this->metaTablesSQL = "select tablename,'T' from pg_tables where tablename not like 'pg\_%' |
|
87 | 87 | and schemaname not in ( 'pg_catalog','information_schema') |
88 | 88 | union |
89 | 89 | select viewname,'V' from pg_views where viewname not like 'pg\_%' and schemaname not in ( 'pg_catalog','information_schema') "; |
@@ -40,47 +40,47 @@ discard block |
||
40 | 40 | |
41 | 41 | function ADODB_ado_mssql() |
42 | 42 | { |
43 | - $this->ADODB_ado(); |
|
43 | + $this->ADODB_ado(); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | function _insertid() |
47 | 47 | { |
48 | - return $this->GetOne('select @@identity'); |
|
48 | + return $this->GetOne('select @@identity'); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | function _affectedrows() |
52 | 52 | { |
53 | - return $this->GetOne('select @@rowcount'); |
|
53 | + return $this->GetOne('select @@rowcount'); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | function MetaColumns($table) |
57 | 57 | { |
58 | - $table = strtoupper($table); |
|
59 | - $arr= array(); |
|
60 | - $dbc = $this->_connectionID; |
|
58 | + $table = strtoupper($table); |
|
59 | + $arr= array(); |
|
60 | + $dbc = $this->_connectionID; |
|
61 | 61 | |
62 | - $osoptions = array(); |
|
63 | - $osoptions[0] = null; |
|
64 | - $osoptions[1] = null; |
|
65 | - $osoptions[2] = $table; |
|
66 | - $osoptions[3] = null; |
|
62 | + $osoptions = array(); |
|
63 | + $osoptions[0] = null; |
|
64 | + $osoptions[1] = null; |
|
65 | + $osoptions[2] = $table; |
|
66 | + $osoptions[3] = null; |
|
67 | 67 | |
68 | - $adors=@$dbc->OpenSchema(4, $osoptions);//tables |
|
68 | + $adors=@$dbc->OpenSchema(4, $osoptions);//tables |
|
69 | 69 | |
70 | - if ($adors){ |
|
71 | - while (!$adors->EOF){ |
|
72 | - $fld = new ADOFieldObject(); |
|
73 | - $c = $adors->Fields(3); |
|
74 | - $fld->name = $c->Value; |
|
75 | - $fld->type = 'CHAR'; // cannot discover type in ADO! |
|
76 | - $fld->max_length = -1; |
|
77 | - $arr[strtoupper($fld->name)]=$fld; |
|
70 | + if ($adors){ |
|
71 | + while (!$adors->EOF){ |
|
72 | + $fld = new ADOFieldObject(); |
|
73 | + $c = $adors->Fields(3); |
|
74 | + $fld->name = $c->Value; |
|
75 | + $fld->type = 'CHAR'; // cannot discover type in ADO! |
|
76 | + $fld->max_length = -1; |
|
77 | + $arr[strtoupper($fld->name)]=$fld; |
|
78 | 78 | |
79 | - $adors->MoveNext(); |
|
80 | - } |
|
81 | - $adors->Close(); |
|
82 | - } |
|
83 | - $false = false; |
|
79 | + $adors->MoveNext(); |
|
80 | + } |
|
81 | + $adors->Close(); |
|
82 | + } |
|
83 | + $false = false; |
|
84 | 84 | return empty($arr) ? $false : $arr; |
85 | 85 | } |
86 | 86 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | function ADORecordSet_ado_mssql($id,$mode=false) |
94 | 94 | { |
95 | - return $this->ADORecordSet_ado($id,$mode); |
|
95 | + return $this->ADORecordSet_ado($id,$mode); |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | ?> |
99 | 99 | \ No newline at end of file |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | var $fmtTimeStamp = "'Y-m-d H:i:s'"; |
28 | 28 | var $hasInsertID = true; |
29 | 29 | var $hasAffectedRows = true; |
30 | - var $substr = 'substr'; |
|
30 | + var $substr = 'substr'; |
|
31 | 31 | var $metaTablesSQL="select tabname,tabtype from systables where tabtype in ('T','V') and owner!='informix'"; //Don't get informix tables and pseudo-tables |
32 | 32 | |
33 | 33 | |
@@ -64,19 +64,19 @@ discard block |
||
64 | 64 | |
65 | 65 | if (function_exists('ifx_byteasvarchar')) { |
66 | 66 | ifx_byteasvarchar(1); // Mode "0" will return a blob id, and mode "1" will return a varchar with text content. |
67 | - ifx_textasvarchar(1); // Mode "0" will return a blob id, and mode "1" will return a varchar with text content. |
|
68 | - ifx_blobinfile_mode(0); // Mode "0" means save Byte-Blobs in memory, and mode "1" means save Byte-Blobs in a file. |
|
67 | + ifx_textasvarchar(1); // Mode "0" will return a blob id, and mode "1" will return a varchar with text content. |
|
68 | + ifx_blobinfile_mode(0); // Mode "0" means save Byte-Blobs in memory, and mode "1" means save Byte-Blobs in a file. |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
72 | 72 | function ServerInfo() |
73 | 73 | { |
74 | - if (isset($this->version)) return $this->version; |
|
74 | + if (isset($this->version)) return $this->version; |
|
75 | 75 | |
76 | - $arr['description'] = $this->GetOne("select DBINFO('version','full') from systables where tabid = 1"); |
|
77 | - $arr['version'] = $this->GetOne("select DBINFO('version','major') || DBINFO('version','minor') from systables where tabid = 1"); |
|
78 | - $this->version = $arr; |
|
79 | - return $arr; |
|
76 | + $arr['description'] = $this->GetOne("select DBINFO('version','full') from systables where tabid = 1"); |
|
77 | + $arr['version'] = $this->GetOne("select DBINFO('version','major') || DBINFO('version','minor') from systables where tabid = 1"); |
|
78 | + $this->version = $arr; |
|
79 | + return $arr; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | } |
148 | 148 | |
149 | 149 | |
150 | - function &MetaColumns($table) |
|
150 | + function &MetaColumns($table) |
|
151 | 151 | { |
152 | 152 | global $ADODB_FETCH_MODE; |
153 | 153 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $save = $ADODB_FETCH_MODE; |
157 | 157 | $ADODB_FETCH_MODE = ADODB_FETCH_NUM; |
158 | 158 | if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); |
159 | - $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table)); |
|
159 | + $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table)); |
|
160 | 160 | if (isset($savem)) $this->SetFetchMode($savem); |
161 | 161 | $ADODB_FETCH_MODE = $save; |
162 | 162 | if ($rs === false) return $false; |
@@ -181,13 +181,13 @@ discard block |
||
181 | 181 | $fld->not_null = $pr[3]=="N"; //!eos |
182 | 182 | |
183 | 183 | if (trim($rs->fields[3]) != "AAAAAA 0") { |
184 | - $fld->has_default = 1; |
|
185 | - $fld->default_value = $rs->fields[3]; |
|
184 | + $fld->has_default = 1; |
|
185 | + $fld->default_value = $rs->fields[3]; |
|
186 | 186 | } else { |
187 | 187 | $fld->has_default = 0; |
188 | 188 | } |
189 | 189 | |
190 | - $retarr[strtolower($fld->name)] = $fld; |
|
190 | + $retarr[strtolower($fld->name)] = $fld; |
|
191 | 191 | $rs->MoveNext(); |
192 | 192 | } |
193 | 193 |