PHP Classes

PHP Database Operations: Perform common database table record operations

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 yet rated by the usersTotal: 101 All time: 9,798 This week: 455Up
Version License PHP version Categories
db_operations 1.0.2The PHP License5PHP 5, Databases
Description 

Author

This class can perform common database table record operations.

It can connect to a MySQL database server using the MySQLi extension.

The package can perform several types of database queries on a specific table using parameters to compose the SQL strings that will be executed.

Currently, it can compose and execute SQL queries of type SELECT, INSERT, UPDATE and DELETE.

Picture of Akhil s Sakariya
Name: Akhil s Sakariya <contact>
Classes: 1 package by
Country: India India

Example

<?php
//==========Include Db class=========
include("Db_operations.php");
//==========/Include Db class=========


//==============Create db Object===============
$db = new Db_operations();
//==============/Create db Object===============


//================Connection Variables=================
$server = "localhost";
$username = "root";
$password = "";
$database_name = "stud";
//================/Connection Variables=================

//=====================Get Connection======================
$connection = $db->connection($server,$username,$password,$database_name);
//=====================/Get Connection======================


//===========Define All The tables=========
$table_name = "student";
// ==========/Define All The tables=========




// insert()
// Parameters
// 1 - Db Connection
// 2 - Table Name
// 3 - Data array
// Create assoc Array Put key as table column name and value as value
$data = array('name'=>'xyz','rollno'=>11);
$db->insert($connection,$table_name,$data);


// update()
// Parameters
// 1 - Db Connection
// 2 - Table Name
// 3 - Data array
// 4 - where Condition
 
$data = array('rollno'=>99999,'name'=>'xyz');
 
$db->update($connection,$table_name,$data,'id=34');



// delete()
// Parameters
// 1 - Db Connection
// 2 - Table Name
// 3 - where Condition
 
$db->delete($connection,$table_name,"id=34");



// select()
// Parameters
// 1 - Db Connection
// 2 - Table Name
// 3 - Columns name
// 4 - where Condition

$data = array('*');
$data = array('name','id');
$data = $db->select($connection,$table_name,$data,"");
while(
$row = mysqli_fetch_assoc($data))
{
   
print_r($row);
}

?>


  Files folder image Files (2)  
File Role Description
Plain text file Db_operations-1.0.1.php Class Main File
Accessible without login Plain text file example.php Example demo file

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:101
This week:0
All time:9,798
This week:455Up