PHP Classes

PHP Database Operations: Perform common database table record operations

Recommend this page to a friend!
  Info   View files Example   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 100 All time: 9,762 This week: 150Up
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
Age: ???
All time rank: 4403301 in India India
Week rank: 364 Up17 in India India Up

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  
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

 Version Control Unique User Downloads Download Rankings  
 0%
Total:100
This week:0
All time:9,762
This week:150Up