Version 1.2 is out now. Click here to check what’s new in V1.2*
Version 1.1 is out now. Click here to check what’s new in V1.1*
- Now supports PDO Transactions also **
Simplified DB is a PHP database abstration class that helps developer perform MySQL operations easily using PDO, Mysqli and Mysql. Using Simplified DB, you can easily create and run both simple and advanced database driven application in PHP without having any knowledge of SQL.
Simplified DB provide a single solution for all you need to perform CRUD operation on Mysql DB using PHP as it covers all the 3 major ways (PDO, Mysqli and Mysql) of doing it.It has various shorthand methods that reduce code lines, improve readability of your code, improve security, performance & simplify your database operations.
Click here for more examples and documentation
Examples
// include appropriate class file
require_once("SimplifiedDBPDO.php");
//create object of class
$sdb= new SimplifiedDB();
/** Connect to database **/
$sdb->dbConnect("servername","username","password","database");
/* Example of insert update and delete operations*/
$sdb->dbInsert("table_name",array("first_name"=>"Jerry","last_name"=>"Smith"));
$sdb->dbUpdate("table_name",array("first_name"=>"John"),array("user_id"=>15));
$sdb->dbDelete("table_name",array("user_id"=>15));
/*Selecting all data*/
$sdb->dbSelect("table_name");
/*Selecting some columns(first_name,last_name) with where condition(user_id=10)*/
$sdb->dbSelect("table_name",array("first_name","last_name"),array("user_id"=>10));
// Example of using != operator,(you can use any valid operator like '>','<','>=','<=')
$result=$sdb->dbSelect("table_name",array("firstName","email"),array("gender !="=>"male"));
// Applying group by, order by,limit,like conditions
// you need to set them before calling select function
$sdb->group_by_column="gender";
$sdb->order_by_column="first_name";
$sdb->limit_val="0,10";
$sdb->like_cols=array("firstname"=>"r%");
$sdb->in=array("user_id"=>"'10','8','12'");
$res=$sdb->dbSelect("table",array("first_name","last_name"),array("gender"=>"male"));
It supports following SQL operations and commands using PDO, Mysqli and Mysql.
SELECT
INSERT
UPDATE
DELETE
WHERE CONDITION
JOIN
GROUP BY
ORDER BY
LIMIT
LIKE
BETWEEN
IN
NOT IN
(!=, >= ,<=,>,<) OPERATORS
HAVING
version 1.2 released 16 Aug 2013
1. Added new function for batch update operation
2. Added new function for batch delete operation
3. Fixed a small bug related to '>=','<=' and using alias in join condition
version 1.1 released 15 may 2013
1. Supports PDO transaction
2. Reset Setting option added
3. Get all table names from database function added
4. Get value of single variable function added
5. Short hand function for getting all rows from table added
6. character set support added
7. fixed a small bug in update where condition
If you like the script ,please take a min. to rate it. It will motivate me to add new features. Thanks