A PHP file for handle database
Overview
- Generate SQL
- View table data from database
- Insert data into table
- Update table
- Delete data from Table
- Trigger
- Index management
Clone a copy of the main repo
git https://github.com/zxalif/php-mysql-handler.git
Set host, username, password, and database name
- conn/conn.php
$host = 'localhost';
$user = 'root';
$pwd = '';
$db = 'cms';
include('php-database-handler/index.php');
$cms = new SQLCreate();
$sql = $cms->generate('table_name', null, $type='view');
echo $sql;
> SELECT * FROM table_name
include('php-database-handler/index.php');
$cms = new SQLCreate();
$sql = $cms->generate('table_name', null, $type='view', array('limit'=>10));
echo $sql;
> SELECT * FROM table_name LIMIT 10
include('php-database-handler/index.php');
$cms = new SQLCreate();
$sql = $cms->generate('table_name', null, $type='view', array('limit'=>array(10, 20)));
echo $sql;
> SELECT * FROM table_name LIMIT 10, 20
include('php-database-handler/index.php');
$cms = new SQLCreate();
$sql = $cms->generate('table_name', array('id'=>'1', 'name'=>'zxalif'), $type='insert');
echo $sql;
> INSERT INTO table_name(id, name) VALUES("1", "zxalif")
👍