PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of Hicri   PHP MySQL Query Builder Class   README.md   Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Read me
Class: PHP MySQL Query Builder Class
Compose and execute SQL queries on MySQL using PDO
Author: By
Last change:
Date: 3 years ago
Size: 2,338 bytes
 

Contents

Class file image Download

PHP-MySQL-Class

Mysql Connection V1

Initialize

<?php
define('DBHost', 'localhost');
define('DBName', 'northwind');
define('DBUser', 'root');
define('DBPassword', '');
define("connection","connection");
$db = new DatabaseController(DBHost, DBName, DBUser, DBPassword,connection);

?>

Basic Table // use northwind

table "orders"

| OrderID | EmployeeID | ShipName |:-----------:|:------------:|:------------:| | 10249 | 6 | red | 10250 | 4 | yellow | 10251 | 3 | green | 10252 | 4 | yellow | 10253 | 3 | red

Insert Method (TableName, Data = array()):

TableName, Data:

$tableName = "Orders";

$data = Array
(
  "ShipName" => "Blue",
  "ShipAddress" => "Nottingham",
  "ShipCity" => "UK"
);

Insert Method
<?php
$methodInsert = $method->Insert($tableName,$data);
?>

Update Method (TableName, Id = array() , Data = array()):

TableName, Id , Data:

$tableName = "Orders";

$Id = array(
 "OrderID" => "1"
);

$data = Array
(
  "ShipName" => "Blue",
  "ShipAddress" => "Nottingham",
  "ShipCity" => "UK"
);

Update Method
<?php
$methodUpdate = $method->Update($tableName', $id, $data);
?>

Delete Method (TableName, Id = array()):

TableName, Id:

$tableName = "Orders";

$Id = array(
 "OrderID" => "1"
);

Delete Method
<?php
$methodDelete = $method->Delete($tableName,$id);
?>

Select_all Method (TableName):

TableName:

$tableName = "Orders";

Select_all Method
<?php
$methodSelectAll = $method->Select_all($tableName);
?>

Select_ch Method (TableName, Data = array()):

TableName, Data:

$tableName = "Orders";

$data = Array
(
  "ShipName", "ShipAddress", "ShipCity"
);

Select_ch Method
<?php
$methodSelectCh = $method->Select_ch($tableName,$data);
?>

Select_wh Method (TableName, Data = array(), Conn = array(), If = array()):

TableName, Data, Conn, If:

$tableName = "Orders";

$data = Array
(  
    "EmployeeID" => "4"
);

$conn = Array
(  
    "!="
);

$if = Array
(  
    "AND"
);

Select_wh Method
<?php
$methodSelectWh =  $method->Select_wh($tableName, $data, $conn, $if);
?>