DBConnect: MySQL database access wrapper

Recommend this page to a friend!
  Info   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 68%Total: 3,022 All time: 1,203 This week: 162Up
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
Age: 46
All time rank: 105246 in United Kingdom
Week rank: 625 Up17 in United Kingdom Up

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  
This week:0
All time:1,203
This week:162Up
User Ratings User Comments (1)
 All time
11 years ago (kishore kumar)

For more information send a message to info at phpclasses dot org.