PHP Classes

Classes of tmchow

Recommend this page to a friend!
  All class groups  >  All authors  >  Classes of tmchow (1)  >  Mission progress status  >  Reputation  
Picture of tmchow
Name: tmchow <contact>
Classes: 1
Country: United States United States
Age: ???
All time rank: 2023290 in United States United States
Week rank: 195 Up19 in United States United States Up
All time users: 1294
Week users: 0
 
  A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   P   Q   R   S   T   U   V   W   X   Y   Z  
  Files folder image phpPostgreSQLdB  
Abstraction layer for PostgreSQL DB
Class that provides an abstraction layer above the PHP PostgreSQL API. This centralizes all the database connection info such as host, port, etc. Same class an be used to connect to multiple databases on different servers and on different ports.

In addition to "normal" stuff that you'd expect from a db abstraction layer, it also supports transactions among other things. Comprehensive error checking/management.

Revision History:
*** see class header for revision history ***

Sample usage:

//// Example #1 ////////////////

include("include/dblib.php");
$db = new phpDB();
$db->connect("foobar");
$db->beginTrans();

if (!$db->exec("INSERT INTO weather VALUES ('Vancouver', 1, 5, 0.25)")) {
echo $db->errorMsg();
$db->rollbackTrans();
}

$db->commitTrans();
if (!$db->exec("SELECT * FROM weather"))
echo $db->errorMsg();

//// Example #2 ////////////////

include("include/dbutil.php");
$db = new phpDB();
$db->connect("foobar");
$db->exec("SELECT * from TREVIN");

while ($db->nextRow()) {

// can access like objects!
$rs1 = $db->fobject();
echo "$rs->description : $rs->color : $rs->price <br>";

// Can access like an array!
$rs2 = $db->farray();
echo "$rs2[0] : $rs2[1] : $rs[2] <br>";
}


  A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   P   Q   R   S   T   U   V   W   X   Y   Z