slvler/mysql-connectors

Mysql driver development that can be used on the php side

v1.2.0 2023-12-22 11:02 UTC

This package is auto-updated.

Last update: 2024-04-19 14:42:58 UTC


README

tests Latest Stable Version Latest Unstable Version License

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.