PHP MySQL Database: Connect and query a MySQL database

Recommend this page to a friend!
  Info   View files Example   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog (1)    
Ratings Unique User Downloads Download Rankings
StarStar 35%Total: 524 All time: 5,641 This week: 181Up
Version License PHP version Categories
php-simple-db-class 1.0.0GNU General Publi...5PHP 5, Databases
Description Author

This class can connect and query a MySQL database.

It parses a INI file to extract the database server host, user, password and database name to connect.

The class can perform arbitrary SQL queries and extract the query results into arrays.

The database connection is closed when the object is destroyed.

Recommendations

mysql database
script for update mysql database

Picture of Waqar Ahmed
Name: Waqar Ahmed <contact>
Classes: 3 packages by
Country: United Kingdom
Innovation award
Innovation award
Nominee: 1x

Details

PHP-Database-Class

OOP Database class for PHP MySQL connection and insert, update, delete and select query

CONFIG File

All database configurations are stored in seperate config.ini.php file, which can be kept off document root.

DATABASE CONNECTION AND QUERIES

Database class loads configuration file and establishes a MySQLi connect in constructor so just creating an instance of class connects you with database.

e.g:

$db = new MySQLDb; // would connect to database

To run any kind of query (select, insert, update, delete), pass SQL query to query method of class

e.g:

$query = "select * from table_name";

$result = $db->query($query); //$result object returns true on successful execution

To select rows after executing query, use fetch() method and store result in an array

e.g:

$rows = $db->fetch();

Examples of Use:

examples.php has a create table SQL to create a test table and load some data in it

Examples includes quering database, checking result object and examples of select, insert, update and delete queries.

  Files folder image Files  
File Role Description
Accessible without login Plain text file config.ini.php Conf. Configuration script
Plain text file database.class.php Class Class source
Accessible without login Plain text file example.php Example Example script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 100%
Total:524
This week:0
All time:5,641
This week:181Up
User Ratings User Comments (5)
 All time
Utility:41%StarStarStar
Consistency:41%StarStarStar
Documentation:50%StarStarStar
Examples:58%StarStarStar
Tests:-
Videos:-
Overall:35%StarStar
Rank:3179
  
For more information send a message to info at phpclasses dot org.