PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of Waqar Ahmed  >  PHP MySQL Database  >  README.md  >  Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP MySQL Database
Connect and query a MySQL database
Author: By
Last change:
Date: 4 years ago
Size: 1,130 bytes
 

Contents

Class file image Download

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.

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