Ratings | | Unique User Downloads | | Download Rankings |
Not enough user ratings | | Total: 226 | | All time: 8,204 This week: 51 |
Version | | License | | PHP version | | Categories |
db_manager 1.0.1 | | Custom (specified... | | 5 | | PHP 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. | |
|
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.
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.