PHP Classes

File: index.php

Recommend this page to a friend!
  Classes of Muhammad Umer Farooq   PHP MySQL Manipulation Class   index.php   Download  
File: index.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP MySQL Manipulation Class
Compose and execute MySQL queries using PDO
Author: By
Last change: Apply fixes from StyleCI
Date: 6 years ago
Size: 1,243 bytes
 

Contents

Class file image Download
<?php

require_once 'classes/MYSQL.php';

$mysql = new MYSQL('localhost', 'root', '');

/* Creating tables */
//$mysql->CreateDb("PHP");

/* deleting database */
//$mysql->DeleteDb("PHP");

/* creating table */
/*$mysql->CreateTbl("PHP","CREATE TABLE users(
    id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
    first_name VARCHAR(30) NOT NULL,
    last_name VARCHAR(30) NOT NULL,
    email VARCHAR(70) NOT NULL UNIQUE
)");*/

/* deleting table */
//$mysql->DeleteTbl("PHP","users");

/* inserting records */
//$id = $mysql->Insert('users','PHP',['first_name'=>'Malik Uner','last_name'=> 'Farooq','email'=> 'lablnet01@gmail.com']);

/* updating database */
//$id = 1;
//$mysql->Update(['table'=>'users','db_name'=>'PHP','columns'=>['first_name' => 'Malik Umer'],'wheres'=>['id ='. 1]]);

/* selecting values */
$result = $mysql->Select(['table'=>'users', 'db_name'=>'PHP', 'wheres'=>['email ='.$mysql->Quote('lablnet01@gmail.com')]]);

print_r($result);

/* deleting the records */
//$mysql->Delete(['table'=>'users','db_name'=>'PHP','wheres'=>['id ='. 9]]);

/* Counting the records */
//echo $mysql->Count(['table'=>'users','db_name'=>'PHP','wheres'=>['id ='. 9]]);

//Close the connection its recommended to clsoe connection
$mysql->Close();