PHP Classes

DB Manager: Execute common SQL queries to a MySQL database

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 226 All time: 8,204 This week: 51Up
Version License PHP version Categories
db_manager 1.0.1Custom (specified...5PHP 5, Databases
Description 

Author

This class can execute common SQL queries to a MySQL database.

It can connect to a MySQL database and execute arbitrary queries or queries composed programatically from parameter values.

Currently it can execute SELECT queries to a given table, INSERT queries from a list of fields and values, and UPDATE or DELETE queries to table records matching a condition.

Picture of Kabir Hossain
  Performance   Level  

 

Example

<?php
   
include_once('Database.php');
   
$db = new Database('localhost','root','','db_example');
   
   
//insert example
       
$data = array(
           
'name' => 'Demo Insert',
           
'role' => 'Editor'
       
);
       
$db->insertData($table='users',$data);
       
//for getting insert id
        //echo $db->insertData($table='users',$data)->insertId();
       
    //select example
   
$select_data = $db->selectData($table='users', $select='id,name,role', $where=null, $or_where=null, $orderby='id', $limit=10, $offset=null);
   
print_r($select_data->result());
   
   
//update example
       
$data = array(
           
'name' => 'Demo Update',
           
'role' => 'Editor'
       
);
       
$where = 'id=4';// using string
        //$where = array('id'=>4);//using array
       
$db->updateData($table='users',$data,$where);

   
//delete example
       
$where = array('id'=>4,'status'=>0);//using array
        //$where = 'id=5 AND status=0';// using string
       
$db->deleteData($table='users',$where);
         
   


Details

db_manager

This class can query MySQL databases using SQL.

It can establish a connection to a MySQL server and execute SQL queries to the database tables.

The class can execute SQL SELECT, INSERT, UPDATE and DELETE queries from parameters that specify the tables, the fields and its values.

You can give parameter as a string or array.


  Files folder image Files (5)  
File Role Description
Plain text file Database.php Class Class source
Accessible without login Plain text file db_example.sql Data Auxiliary data
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

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  
 100%
Total:226
This week:0
All time:8,204
This week:51Up