• Main Page
  • Data Structures
  • Files
  • File List

oracleResultset.php

Go to the documentation of this file.
00001 <?php
00002 
00003 /**
00004  * Oracle database query resultset class
00005  *
00006  * @package objSQL
00007  * @version 2.1.0
00008  * @author MT Jordan <mtjo62@gmail.com>
00009  * @link http://objsql.sourceforge.net
00010  * @copyright 2004-2010 openSource Partners
00011  * @license LGPL
00012  * @revision $Id: oracleResultset.php,v 1.6 2008-01-27 12:48:21-05 mt_jordan Exp $
00013  */
00014 
00015 class oracleResultset
00016 {
00017     /**********************************************
00018      * Internal variables
00019      *********************************************/
00020 
00021     /**
00022      * Query resultset record
00023      *
00024      * @access private
00025      * @var    array
00026      */
00027     private $objRecord = array();
00028 
00029     /**
00030      * Query resultset object
00031      *
00032      * @access private
00033      * @var    mixed
00034      */
00035     private $objResult;
00036 
00037     /**********************************************
00038      * Class methods
00039      *********************************************/
00040 
00041     /**
00042      * Constructor
00043      *
00044      * @access public
00045      * @param  mixed $result
00046      */
00047     public function __construct( $result )
00048     {
00049         $this->objResult = $result;
00050     }
00051 
00052     /**
00053      * Returns num of affected rows from insert/delete/update query
00054      *
00055      * @access public
00056      * @return int
00057      */
00058     public function affected_rows()
00059     {
00060         if ( $this->objResult )
00061             return oci_num_rows( $this->objResult );
00062     }
00063 
00064     /**
00065      * Return resultset as assoc array
00066      *
00067      * @access public
00068      * @return mixed
00069      */
00070     public function fetch_array()
00071     {
00072         if ( $this->objResult )
00073         {
00074             $this->objRecord = oci_fetch_assoc( $this->objResult );
00075 
00076             return ( $this->objRecord !== false );
00077         }
00078     }
00079 
00080     /**
00081      * Return resultset as object
00082      *
00083      * @access public
00084      * @return mixed
00085      */
00086     public function fetch_object()
00087     {
00088         if ( $this->objResult )
00089             return oci_fetch_object( $this->objResult );
00090     }
00091 
00092     /**
00093      * Return resultset as numeric array
00094      *
00095      * @access public
00096      * @return mixed
00097      */
00098     public function fetch_row()
00099     {
00100         if ( $this->objResult )
00101         {
00102             $this->objRecord = oci_fetch_row( $this->objResult );
00103 
00104             return ( $this->objRecord !== false );
00105         }
00106     }
00107 
00108     /**
00109      * Return resultset record
00110      *
00111      * @access public
00112      * @param  mixed $field
00113      * @return mixed
00114      */
00115     public function field( $field )
00116     {
00117         if ( $this->objResult )
00118         {
00119             if ( get_magic_quotes_runtime() )
00120                 return stripslashes( $this->objRecord[strtoupper( $field )] );
00121             else
00122                 return $this->objRecord[strtoupper( $field )];
00123         }
00124     }
00125 
00126     /**
00127      * Free resultset memory - destroy resultset object
00128      *
00129      * @access public
00130      */
00131     public function flush()
00132     {
00133         if ( $this->objResult )
00134         {
00135             oci_free_statement( $this->objResult );
00136             $this->objRecord = array();
00137             $this->objResult = null;
00138         }
00139     }
00140 
00141     /**
00142      * Return num fields from select query
00143      *
00144      * @access public
00145      * @return int
00146      */
00147     public function num_fields()
00148     {
00149         if ( $this->objResult )
00150             return oci_num_fields( $this->objResult );
00151     }
00152 
00153     /**
00154      * Return num of rows from select query - MUST be used with "select count(*)"
00155      *
00156      * @access public
00157      * @return int
00158      */
00159     public function num_rows()
00160     {
00161         if ( $this->objResult )
00162         {
00163             while ( $row = oci_fetch_row( $this->objResult ) )
00164                 return $row[0];
00165         }
00166     }
00167 
00168     /**
00169      * Return resultset object
00170      *
00171      * @access public
00172      * @return mixed
00173      */
00174     public function result()
00175     {
00176         return $this->objResult;
00177     }
00178 }
00179 
00180 ?>

Generated on Sat Jul 10 2010 15:14:39 for objSQL 2.1.0 by  doxygen 1.7.1