4 * The oci8 extension is fairly weak and doesn't support oci_num_rows, among
5 * other things. We use a wrapper class to handle that and other
6 * Oracle-specific bits, like converting column names back to lowercase.
14 private $columns = [];
16 private function array_unique_md( $array_in ) {
20 foreach ( $array_in as $item ) {
21 $hash = md5( serialize( $item ) );
22 if ( !isset( $array_hashes[$hash] ) ) {
23 $array_hashes[$hash] = $hash;
32 * @param IDatabase $db
33 * @param resource $stmt A valid OCI statement identifier
36 function __construct( &$db, $stmt, $unique = false ) {
39 $this->nrows
= oci_fetch_all( $stmt, $this->rows
, 0, -1, OCI_FETCHSTATEMENT_BY_ROW | OCI_NUM
);
40 if ( $this->nrows
=== false ) {
41 $e = oci_error( $stmt );
42 $db->reportQueryError( $e['message'], $e['code'], '', __METHOD__
);
49 $this->rows
= $this->array_unique_md( $this->rows
);
50 $this->nrows
= count( $this->rows
);
53 if ( $this->nrows
> 0 ) {
54 foreach ( $this->rows
[0] as $k => $v ) {
55 $this->columns
[$k] = strtolower( oci_field_name( $stmt, $k +
1 ) );
60 oci_free_statement( $stmt );
63 public function free() {
67 public function seek( $row ) {
68 $this->cursor
= min( $row, $this->nrows
);
71 public function numRows() {
75 public function numFields() {
76 return count( $this->columns
);
79 public function fetchObject() {
80 if ( $this->cursor
>= $this->nrows
) {
83 $row = $this->rows
[$this->cursor++
];
84 $ret = new stdClass();
85 foreach ( $row as $k => $v ) {
86 $lc = $this->columns
[$k];
93 public function fetchRow() {
94 if ( $this->cursor
>= $this->nrows
) {
98 $row = $this->rows
[$this->cursor++
];
100 foreach ( $row as $k => $v ) {
101 $lc = $this->columns
[$k];