Skip to content

Mysql driver development that can be used on the php side

License

Notifications You must be signed in to change notification settings

slvler/php-mysql-connectors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-mysql-connectors

tests Latest Stable Version Latest Unstable Version License Total Downloads

Mysql driver development that can be used on the php side

Installation

To install this package tou can use composer:

composer require slvler/mysql-connectors

Usage

use slvler\mysqlconnectors\Constant;
use slvler\mysqlconnectors\Config\Method;
use slvler\mysqlconnectors\Database\DatabaseController;

$Constant = new Constant();

$db = new DatabaseController($Constant->showDBHost(), $Constant->showDBName(), $Constant->showDBUser(), $Constant->showDBPassword(), $Constant->showConnection());

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

$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

$methodUpdate = $method->Update($tableName', $id, $data);

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

TableName, Id:

$tableName = "Orders";

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

Delete Method

$methodDelete = $method->Delete($tableName,$id);

Select_all Method (TableName):

TableName:

$tableName = "Orders";

Select_all Method

$methodSelectAll = $method->Select_all($tableName);

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

TableName, Data:

$tableName = "Orders";

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

Select_ch Method

$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

$methodSelectWh =  $method->Select_wh($tableName, $data, $conn, $if);

Testing

vendor\bin\phpunit

Credits

License

The MIT License (MIT). Please see License File for more information.