[phplib] db_oci8.inc patches From: Ignatius Teo (iteo <email protected>)
Date: 05/09/01

Folks,

PEAR/phplib debate and issues aside, (well, I'm basically ignoring PEAR for
a number of reasons...least of which we are still running on 3.0.17)....

I have patched the following bugs in v7.2c for db_oci8. If someone would
like to put it back into CVS, that would be good, otherwise, just ignore.

The changed functions are:

  function affected_rows() {
          # iteo - 10 May 2001
          # OCIrowcount only returns the number of affected rows
          # NOT the number of rows from a SELECT
    return OCIrowcount($this->Parse);
  }

  ## iteo - 10 May 2001
  ## Hacked from db_oracle.inc (7.2c)
  ## Known bugs: It will not work for SELECT DISTINCT and any
  ## other constructs which are depending on the resulting rows.
  ## So you *really need* to check every query you make, if it
  ## will work with it.
  ##
  ## Also, for a qualified replacement you need to parse the
  ## selection, cause this will fail: "SELECT id, from FROM ...").
  ## "FROM" is - as far as I know a keyword in Oracle, so it can
  ## only be used in this way. But you have been warned.
  function num_rows() {
    $this->connect();
    ## this is the important part and it is also the HACK!
    if (eregi("^[[:space:]]*SELECT[[:space:]]",$this->lastQuery) ) {
      $from_pos = strpos(strtoupper($this->lastQuery),"FROM");
      $q = "SELECT count(*) ". substr($this->lastQuery, $from_pos);
        $cParse = OCIParse($this->Link_ID,$q);
        OCIExecute($cParse);
        $nrows = OCIFetchStatement($cParse,$count);
        return $nrows;
    } else {
      $this->halt("Last Query was not a SELECT: $this->lastQuery");
    }
  }

  function nf() {
    return $this->num_rows();
  }

  function np() {
    print $this->num_rows();
  }

  function f($Name) {
    if (is_object($this->Record[$Name]))
    {
      # iteo - 10 May 2001
      #return $this->Record[$Name]->load();
      return $this->Record[$Name];
    } else
    {
      return $this->Record[$Name];
    }
  }

Ignatius Teo
Project Manager, Internet Access Services
Information Technology Directorate
Southern Cross University
PO Box 157, Lismore NSW 2480
Email: iteo_at_scu_edu_au
Phone: +61 2 6620-3221
Fax : +61 2 6620-3033
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GB/IT$ d++(-)@ s++:++@ a>? C++++ UL !P$ L+
!E W+$ N- o? !K w O---- M- V PS PE++ Y+(--)
PGP- t++@ 5-- X++@ R* tv- b+ DI++ D++@ G
e++ h---- r+++ y++++**
------END GEEK CODE BLOCK------

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>