MediaWiki REL1_33
ORAResult.php
Go to the documentation of this file.
1<?php
2
4
11class ORAResult {
12 private $rows;
13 private $cursor;
14 private $nrows;
15
16 private $columns = [];
17
18 private function array_unique_md( $array_in ) {
19 $array_out = [];
20 $array_hashes = [];
21
22 foreach ( $array_in as $item ) {
23 $hash = md5( serialize( $item ) );
24 if ( !isset( $array_hashes[$hash] ) ) {
25 $array_hashes[$hash] = $hash;
26 $array_out[] = $item;
27 }
28 }
29
30 return $array_out;
31 }
32
38 function __construct( &$db, $stmt, $unique = false ) {
39 $this->db =& $db;
40
41 $this->nrows = oci_fetch_all( $stmt, $this->rows, 0, -1, OCI_FETCHSTATEMENT_BY_ROW | OCI_NUM );
42 if ( $this->nrows === false ) {
43 $e = oci_error( $stmt );
44 $db->reportQueryError( $e['message'], $e['code'], '', __METHOD__ );
45 $this->free();
46
47 return;
48 }
49
50 if ( $unique ) {
51 $this->rows = $this->array_unique_md( $this->rows );
52 $this->nrows = count( $this->rows );
53 }
54
55 if ( $this->nrows > 0 ) {
56 foreach ( $this->rows[0] as $k => $v ) {
57 $this->columns[$k] = strtolower( oci_field_name( $stmt, $k + 1 ) );
58 }
59 }
60
61 $this->cursor = 0;
62 oci_free_statement( $stmt );
63 }
64
65 public function free() {
66 unset( $this->db );
67 }
68
69 public function seek( $row ) {
70 $this->cursor = min( $row, $this->nrows );
71 }
72
73 public function numRows() {
74 return $this->nrows;
75 }
76
77 public function numFields() {
78 return count( $this->columns );
79 }
80
81 public function fetchObject() {
82 if ( $this->cursor >= $this->nrows ) {
83 return false;
84 }
85 $row = $this->rows[$this->cursor++];
86 $ret = new stdClass();
87 foreach ( $row as $k => $v ) {
88 $lc = $this->columns[$k];
89 $ret->$lc = $v;
90 }
91
92 return $ret;
93 }
94
95 public function fetchRow() {
96 if ( $this->cursor >= $this->nrows ) {
97 return false;
98 }
99
100 $row = $this->rows[$this->cursor++];
101 $ret = [];
102 foreach ( $row as $k => $v ) {
103 $lc = $this->columns[$k];
104 $ret[$lc] = $v;
105 $ret[$k] = $v;
106 }
107
108 return $ret;
109 }
110}
serialize()
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
The oci8 extension is fairly weak and doesn't support oci_num_rows, among other things.
Definition ORAResult.php:11
__construct(&$db, $stmt, $unique=false)
Definition ORAResult.php:38
seek( $row)
Definition ORAResult.php:69
array_unique_md( $array_in)
Definition ORAResult.php:18
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
Definition hooks.txt:2003
returning false will NOT prevent logging $e
Definition hooks.txt:2175
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:38