PHP Classes

Simply MySQL DB: Execute common MySQL queries using MySQLi

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: 354 All time: 6,969 This week: 455Up
Version License PHP version Categories
simply-mysql 2.0Artistic License5.0PHP 5, Databases
Description 

Author

This class can execute common MySQL queries using MySQLi.

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

The class can execute SQL SELECT, INSERT, UPDATE, DELETE queries with parameters that define tables, the list of fields and their values, and condition clauses.

For SELECT queries the result counts and result set rows are returned separately.

Picture of arif purwanto
  Performance   Level  

 

Example

<?php
include "mysql_class.php";
$db = new mysqlDatabase("localhost","root","","test");
$table = array("coba");
$fld = array("*");
if(
$db->dbSelect($table,$fld)){
    echo
$db->getNumRows();
    while(
$data=$db->getRows()){
       
var_dump($data);
    }
} else {
   
trigger_error($db->getErrorMessage(),E_USER_ERROR);
}

$dtInsert=array("user"=>"admin","pass"=>"123");
if(
$db->dbInsert("coba",$dtInsert)){
    echo
"Berhasil";
} else {
   
trigger_error($db->getErrorMessage(),E_USER_ERROR);
}
$dtUpdate = array("pass"=>"Administrator");
if(
$db->dbUpdate("coba",$dtUpdate,"user = 'admin'")){
    echo
"Berhasil";
} else {
   
trigger_error($db->getErrorMessage(),E_USER_ERROR);
}
if(
$db->dbDelete("coba","user='admin'")){
    echo
"Berhasil";
} else {
   
trigger_error($db->getErrorMessage(),E_USER_ERROR);
}
?>


  Files folder image Files (2)  
File Role Description
Accessible without login Plain text file example.php Example example
Plain text file mysql_class.php Class Simply Mysql Database v2.0

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:354
This week:0
All time:6,969
This week:455Up