Index: trunk/phase3/includes/db/DatabaseOracle.php |
— | — | @@ -30,8 +30,9 @@ |
31 | 31 | class ORAResult { |
32 | 32 | private $rows; |
33 | 33 | private $cursor; |
34 | | - private $stmt; |
35 | 34 | private $nrows; |
| 35 | + |
| 36 | + private $columns = array(); |
36 | 37 | |
37 | 38 | private function array_unique_md( $array_in ) { |
38 | 39 | $array_out = array(); |
— | — | @@ -63,12 +64,18 @@ |
64 | 65 | $this->nrows = count( $this->rows ); |
65 | 66 | } |
66 | 67 | |
| 68 | + if ($this->nrows > 0) { |
| 69 | + foreach ( $this->rows[0] as $k => $v ) { |
| 70 | + $this->columns[$k] = strtolower( oci_field_name( $stmt, $k + 1 ) ); |
| 71 | + } |
| 72 | + } |
| 73 | + |
67 | 74 | $this->cursor = 0; |
68 | | - $this->stmt = $stmt; |
| 75 | + oci_free_statement( $stmt ); |
69 | 76 | } |
70 | 77 | |
71 | 78 | public function free() { |
72 | | - oci_free_statement( $this->stmt ); |
| 79 | + unset($this->db); |
73 | 80 | } |
74 | 81 | |
75 | 82 | public function seek( $row ) { |
— | — | @@ -80,7 +87,7 @@ |
81 | 88 | } |
82 | 89 | |
83 | 90 | public function numFields() { |
84 | | - return oci_num_fields( $this->stmt ); |
| 91 | + return count($this->columns); |
85 | 92 | } |
86 | 93 | |
87 | 94 | public function fetchObject() { |
— | — | @@ -90,7 +97,7 @@ |
91 | 98 | $row = $this->rows[$this->cursor++]; |
92 | 99 | $ret = new stdClass(); |
93 | 100 | foreach ( $row as $k => $v ) { |
94 | | - $lc = strtolower( oci_field_name( $this->stmt, $k + 1 ) ); |
| 101 | + $lc = $this->columns[$k]; |
95 | 102 | $ret->$lc = $v; |
96 | 103 | } |
97 | 104 | |
— | — | @@ -105,7 +112,7 @@ |
106 | 113 | $row = $this->rows[$this->cursor++]; |
107 | 114 | $ret = array(); |
108 | 115 | foreach ( $row as $k => $v ) { |
109 | | - $lc = strtolower( oci_field_name( $this->stmt, $k + 1 ) ); |
| 116 | + $lc = $this->columns[$k]; |
110 | 117 | $ret[$lc] = $v; |
111 | 118 | $ret[$k] = $v; |
112 | 119 | } |
— | — | @@ -349,43 +356,43 @@ |
350 | 357 | } |
351 | 358 | |
352 | 359 | function freeResult( $res ) { |
353 | | - if ( $res instanceof ORAResult ) { |
354 | | - $res->free(); |
355 | | - } else { |
356 | | - $res->result->free(); |
| 360 | + if ( $res instanceof ResultWrapper ) { |
| 361 | + $res = $res->result; |
357 | 362 | } |
| 363 | + |
| 364 | + $res->free(); |
358 | 365 | } |
359 | 366 | |
360 | 367 | function fetchObject( $res ) { |
361 | | - if ( $res instanceof ORAResult ) { |
362 | | - return $res->numRows(); |
363 | | - } else { |
364 | | - return $res->result->fetchObject(); |
| 368 | + if ( $res instanceof ResultWrapper ) { |
| 369 | + $res = $res->result; |
365 | 370 | } |
| 371 | + |
| 372 | + return $res->fetchObject(); |
366 | 373 | } |
367 | 374 | |
368 | 375 | function fetchRow( $res ) { |
369 | | - if ( $res instanceof ORAResult ) { |
370 | | - return $res->fetchRow(); |
371 | | - } else { |
372 | | - return $res->result->fetchRow(); |
| 376 | + if ( $res instanceof ResultWrapper ) { |
| 377 | + $res = $res->result; |
373 | 378 | } |
| 379 | + |
| 380 | + return $res->fetchRow(); |
374 | 381 | } |
375 | 382 | |
376 | 383 | function numRows( $res ) { |
377 | | - if ( $res instanceof ORAResult ) { |
378 | | - return $res->numRows(); |
379 | | - } else { |
380 | | - return $res->result->numRows(); |
| 384 | + if ( $res instanceof ResultWrapper ) { |
| 385 | + $res = $res->result; |
381 | 386 | } |
| 387 | + |
| 388 | + return $res->numRows(); |
382 | 389 | } |
383 | 390 | |
384 | 391 | function numFields( $res ) { |
385 | | - if ( $res instanceof ORAResult ) { |
386 | | - return $res->numFields(); |
387 | | - } else { |
388 | | - return $res->result->numFields(); |
| 392 | + if ( $res instanceof ResultWrapper ) { |
| 393 | + $res = $res->result; |
389 | 394 | } |
| 395 | + |
| 396 | + return $res->numFields(); |
390 | 397 | } |
391 | 398 | |
392 | 399 | function fieldName( $stmt, $n ) { |