PHP Classes

DBConnect: MySQL database access wrapper

Recommend this page to a friend!
     
  Info   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 68%Total: 3,027 All time: 1,213 This week: 67Up
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: 50
All time rank: 106648 in United Kingdom
Week rank: 200 Up10 in United Kingdom Up

Details

/********************************************************************/ 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 error. /********************************************************************/ /********************************************************************/ Functionality: 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 (4)  
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

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:3,027
This week:0
All time:1,213
This week:67Up
User Ratings User Comments (1)
 All time
Utility:87%StarStarStarStarStar
Consistency:81%StarStarStarStarStar
Documentation:81%StarStarStarStarStar
Examples:87%StarStarStarStarStar
Tests:-
Videos:-
Overall:68%StarStarStarStar
Rank:367
 
Excellent
15 years ago (kishore kumar)
80%StarStarStarStarStar