class ORAResult {
private $rows;
private $cursor;
- private $stmt;
private $nrows;
+
+ private $columns = array();
private function array_unique_md( $array_in ) {
$array_out = array();
$this->nrows = count( $this->rows );
}
+ if ($this->nrows > 0) {
+ foreach ( $this->rows[0] as $k => $v ) {
+ $this->columns[$k] = strtolower( oci_field_name( $stmt, $k + 1 ) );
+ }
+ }
+
$this->cursor = 0;
- $this->stmt = $stmt;
+ oci_free_statement( $stmt );
}
public function free() {
- oci_free_statement( $this->stmt );
+ unset($this->db);
}
public function seek( $row ) {
}
public function numFields() {
- return oci_num_fields( $this->stmt );
+ return count($this->columns);
}
public function fetchObject() {
$row = $this->rows[$this->cursor++];
$ret = new stdClass();
foreach ( $row as $k => $v ) {
- $lc = strtolower( oci_field_name( $this->stmt, $k + 1 ) );
+ $lc = $this->columns[$k];
$ret->$lc = $v;
}
$row = $this->rows[$this->cursor++];
$ret = array();
foreach ( $row as $k => $v ) {
- $lc = strtolower( oci_field_name( $this->stmt, $k + 1 ) );
+ $lc = $this->columns[$k];
$ret[$lc] = $v;
$ret[$k] = $v;
}
}
function freeResult( $res ) {
- if ( $res instanceof ORAResult ) {
- $res->free();
- } else {
- $res->result->free();
+ if ( $res instanceof ResultWrapper ) {
+ $res = $res->result;
}
+
+ $res->free();
}
function fetchObject( $res ) {
- if ( $res instanceof ORAResult ) {
- return $res->numRows();
- } else {
- return $res->result->fetchObject();
+ if ( $res instanceof ResultWrapper ) {
+ $res = $res->result;
}
+
+ return $res->fetchObject();
}
function fetchRow( $res ) {
- if ( $res instanceof ORAResult ) {
- return $res->fetchRow();
- } else {
- return $res->result->fetchRow();
+ if ( $res instanceof ResultWrapper ) {
+ $res = $res->result;
}
+
+ return $res->fetchRow();
}
function numRows( $res ) {
- if ( $res instanceof ORAResult ) {
- return $res->numRows();
- } else {
- return $res->result->numRows();
+ if ( $res instanceof ResultWrapper ) {
+ $res = $res->result;
}
+
+ return $res->numRows();
}
function numFields( $res ) {
- if ( $res instanceof ORAResult ) {
- return $res->numFields();
- } else {
- return $res->result->numFields();
+ if ( $res instanceof ResultWrapper ) {
+ $res = $res->result;
}
+
+ return $res->numFields();
}
function fieldName( $stmt, $n ) {