PHP Classes

PHP MySQL Query Builder Class: Compose and execute SQL queries on MySQL using PDO

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 121 All time: 9,491 This week: 455Up
Version License PHP version Categories
php-mysql-class 1.0The PHP License5PHP 5, Databases
Description 

Author

This package can compose and execute SQL queries on MySQL using PDO.

It can connect to a MySQL database using the PDO PHP extension.

The package also provides classes to compose common SQL queries from parameter values and execute them using the database connection class.

Picture of Hicri
  Performance   Level  
Name: Hicri <contact>
Classes: 26 packages by
Country: Turkey Turkey
Age: 30
All time rank: 290948 in Turkey Turkey
Week rank: 45 Up1 in Turkey Turkey Up
Innovation award
Innovation award
Nominee: 4x

Winner: 1x

Example

<?php
require_once "autoload.php";
require_once
"constants.php";

use \
qwerty\Database\DatabaseController as DatabaseController;
use \
qwerty\Config\Method as Method;


$db = new DatabaseController(DBHost, DBName, DBUser, DBPassword,connection);


$cn = $db->MysqlConnection();
//$baglanti = $db->PostgresqlConnection();

$method = new Method($cn);

//$veri = $method->Select_all("orders");
/*

$data = array(
    'ShipName' => "deneme",
    'ShipAddress' => "deneme",
    'ShipCity' => "deneme"
);
*/
//$method = $method->Insert("orders",$data);

$id = array(
 
'OrderID',"CustomerID"
);

/*
$data = array(
    'ShipName' => "12",
    'ShipAddress' => "12",
    'ShipCity' => "12"
);


$method = $method->Update('orders', $id, $data);
*/

//$method = $method->Delete('orders',$id);

$data = array(
   
"EmployeeID" => "4"
);
$con = array("!=");
$if = array("AND");

//$a = $method->Select_ch("orders",$id);

$a = $method->Select_wh('orders',$data,$con,$if);

print_r($a);


?>


Details

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);
?>


  Files folder image Files (10)  
File Role Description
Files folder imagesrc (3 files, 1 directory)
Accessible without login Plain text file README.md Doc. Read me

  Files folder image Files (10)  /  src  
File Role Description
Files folder imageqwerty (2 directories)
  Accessible without login Plain text file autoload.php Aux. Auxiliary script
  Accessible without login Plain text file constants.php Aux. Auxiliary script
  Accessible without login Plain text file Ext.php Example Example script

  Files folder image Files (10)  /  src  /  qwerty  
File Role Description
Files folder imageConfig (3 files)
Files folder imageDatabase (3 files)

  Files folder image Files (10)  /  src  /  qwerty  /  Config  
File Role Description
  Plain text file Method.php Class Class source
  Plain text file Sql.php Class Class source
  Plain text file SqlPattern.php Class Class source

  Files folder image Files (10)  /  src  /  qwerty  /  Database  
File Role Description
  Plain text file Database.php Class Class source
  Plain text file DatabaseController.php Class Class source
  Plain text file DatabaseFace.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:121
This week:0
All time:9,491
This week:455Up