• Main Page
  • Data Structures
  • Files
  • File List

pgsqlResultset.php

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

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