PHP Classes

File: pg-adodb-class.php

Recommend this page to a friend!
  Classes of Jason Sheets   Pseudo PostreSQL ADODB   pg-adodb-class.php   Download  
File: pg-adodb-class.php
Role: Class source
Content type: text/plain
Description: Main Class File
Class: Pseudo PostreSQL ADODB
PostgreSQL ADOdb Replacement
Author: By
Last change: fixed license
Date: 21 years ago
Size: 4,282 bytes
 

Contents

Class file image Download
<?php
/**
Copyright (C) 2002 Jason Sheets <jsheets@shadonet.com>.
All rights reserved.

THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
  
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.
  
3. Neither the name of the project nor the names of its contributors
   may be used to endorse or promote products derived from this software
   without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.

**/

/**
   Name: PostreSQL ADODB Emulation

   Version: 1.0
   Date Released: 11/5/02

   Description: This class is designed to replace ADOdb for applications that do not need
   the full power of ADOdb. This class implements or emulates the functions most common
   scripts will need. You may wish to use this script so that you can move to ADOdb later
   or so you have a common database interface.
  
   Note:
  
   The CacheExecute function does not do any caching, it is the same function as Execute,
   it simply accepts a time variable, if you move to ADoDB your cacheexecute calls will be
   cached.

   Usage:
      See the README.txt file.
   

   Author: Jason Sheets <jsheets@shadonet.com>

   License: This script is distributed under the BSD License, you are free
   to use, or modify it however you like. If you find this script useful please
   e-mail me.
**/


class PG_ADODB {
   var
$dbcon;
 
   function
PG_ADODB() {
   }
     
  
   function
Connect($DB_HOST = 'localhost', $DB_USER, $DB_PASSWORD, $DB_NAME, $DB_PORT = 5432)
   {
   
$this->dbcon = pg_connect ("host=$DB_HOST port=$DB_PORT dbname=$DB_NAME user=$DB_USER password=$DB_PASSWORD") or die('Could Not Connect to Database');
   }
  
   function
CacheExecute($time, $SQL)
   {
     
$newone = new PG_ADODB_EXECUTE($this->dbcon);
     
$newone->Execute($SQL);
     
      return
$newone;
   }
  
   function
Close()
   {
     
pg_close($this->$dbcon);
   }
  
   function
Execute($SQL)
   {
     
$newone = new PG_ADODB_EXECUTE($this->dbcon);
     
$newone->Execute($SQL);
     
      return
$newone;
   }
  
   function
PConnect($DB_HOST, $DB_USER, $DB_PASSWORD, $DB_NAME, $DB_PORT = 5432)
   {
   
$dbcon = pg_pconnect ("host=$DB_HOST port=$DB_PORT dbname=$DB_NAME user=$DB_USER password=$DB_PASSWORD");
   }
}

class
PG_ADODB_EXECUTE {
   var
$dbcon;
   var
$resultset;
  
   function
PG_ADODB_EXECUTE($dbcon = '') {
      if (!empty(
$dbcon)) {
        
$this->dbcon = $dbcon;
      }
   }
  
   function
Close()
   {
     
pg_free_result($this->resultset);
   }
  
   function
Execute($SQL) {
     
$GLOBALS['sqlquerycount']++;
     
$this->resultset = pg_query($this->dbcon, $SQL);
   }
  
   function
FieldCount()
   {
      return
pg_num_fields($this->resultset);
   }
  
   function
FetchRow($TYPE = '')
   {
      return
pg_fetch_array($this->resultset);
   }
      
   function
RecordCount()
   {
      return
pg_num_rows($this->resultset);
   }
  
   function
SelectLimit($SQL, $offset, $limit)
   {
   }
}
?>