A PHP MySQL PDO class
// Require Files;
require_once 'Config.php';
require_once 'PDO_Interface.php';
require_once 'PDO.Class.php';
// Create PDO_Connect Class
$db = new PDO_Connect();
Then inject this SQL
CREATE TABLE `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(255) NOT NULL, `member` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8
<?php
$query = $db->query('id', 'users')->execute();
?>
<?php
$db->insert('users', "`username` , `member`", ":username , :member")
->bind([
'username'=>'Malek Academy',
'member'=>1
])
->execute();
if($db->lastInsertId())
echo 'insert successfuly';
else
echo 'insert failed';
?>
<?php
$db->update('users', "`username` = :username , `member` = :member", 'id', '1')
->bind(
[
'username' => 'Mohammd',
'member' => 0
]
);
if($db->execute())
echo 'update successfuly';
else
echo 'update failed';
?>
<?php
$db->delete('users', 'id', ":id")->bind(['id' => 1]);
if($db->execute())
echo 'delete successfuly';
else
echo 'delete failed';
?>
<?php
$rows_count = $db->query('id', 'users')->execute()->rowCount();
echo $rows_count;
?>
get rows count with binding Safety
<?php
$row_count = $db->query('id', 'users' , "WHERE `username` = :username")
->bind(
[
'username'=>$_GET['user']
])
->execute()->rowCount();
echo $row_count;
?>
<?php
$query = $db->query('*', 'users' , "WHERE `username` = :username")
->bind(
[
'username'=>$_GET['user']
])
->execute()->fetch();
echo '<pre>';
print_r($query);
echo '</pre>';
?>
<?php
$query = $db->query('*', 'users' , "WHERE `member` = :member")
->bind(
[
'member'=>1
])
->execute()->fetchAll();
echo '<pre>';
print_r($query);
echo '</pre>';
?>
<?php
$db->close();
?>