PHP Classes

DBConnect: MySQL database access wrapper

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in
  Info   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2005-10-16 (9 years ago) RSS 2.0 feedStarStarStarStar 68%Total: 2,987 All time: 1,151 This week: 1,184Down
Version License Categories  
mysqlconnect 1.0Free for non-comm...PHP 5, Databases
Description Author  

This class is a MySQL database access wrapper that uses some PHP 5 features to simplify the usual operations.

It establishes a connection with a MySQL server in the class constructor function and closes the connection in the destructor function.

It provides functions for executing SQL queries and return a the row object or multiple rows as an array of objects.

The query statements may be formatted with a variable number of arguments with the sprintf function.

Errors throw exceptions that may be catched by applications.

The class may also generate an error log in a file with formatted error lines that may take a variable number of format arguments.

Picture of herve_tribouilloy
Name: herve_tribouilloy <contact>
Classes: 1 package by
Country: United Kingdom United Kingdom
Age: 40
All time rank: 98543 in United Kingdom United Kingdom
Week rank: 1628 Down72 in United Kingdom United Kingdom Down

Details provided by the author  
Author: Herve Tribouilloy
Date: 15 october 2005
Purpose: connection layer to MySQL with PHP5.0, using stdClass for basic 
container of data. Use of try/catch block allowing handy way to display 

The class focus on the readability of the SQL

This class aims to make easy the exchange of data with MySQL 
using php.

- The update, insert and delete are handled by a function (setQuery)
- The select query returns an array of stdClass objects (getResult, getRecord)

I tested the class on a full project. In this project, 
the connection is only one layer. Validation of the data and 
their parsing is handled by other classes. 

I suppose everybody has his own way to validate and display the error.

How to use it:
1: setup the database
- open a MySQL console, open the text file db.sav
- the first line create a database test1
- the other line create a table named test_table

2: use the example
- load the page example.php and the class connection.php into a class 
folder. The script example.php shows many ways of the use of the class.

  Files folder image Files  
File Role Description
Plain text file connection.php Class class code
Accessible without login Plain text file db.sav Data database source
Accessible without login Plain text file example.php Example example to use connection.php file
Accessible without login Plain text file Readme.txt Doc. readme

 Version Control Unique User Downloads Download Rankings  
 0%Total:2,987All time:1,151
 This week:0This week:1,184Down
User Ratings User Comments (1)  
 All time
5 years ago (kishore kumar)