1. Go to this page and download the library: Download r7di4am/rdb library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
r7di4am / rdb example snippets
tabase connection
$pdo = new PDO("mysql:host=localhost;dbname=test", "root", "");
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Create an instance of the rdb class
use rdb\rdb;
$db = new rdb($pdo);
// Run a query to select all users
$db->query("SELECT * FROM users");
// Fetch all results
$users = $db->fetch_all();
// Print the results
echo "<pre>" . json_encode($users, JSON_PRETTY_PRINT) . "</pre>";
$pdo = new PDO("mysql:host=localhost;dbname=test", "root", "password");
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db = new rdb($pdo);
$db->query("SELECT * FROM users");
$users = $db->fetch_all();
echo "<pre>" . json_encode($users, JSON_PRETTY_PRINT) . "</pre>";
$db->query("SELECT * FROM users WHERE id = :id", ['id' => 2]);
$user = $db->fetch_assoc();
echo "<pre>" . json_encode($user, JSON_PRETTY_PRINT) . "</pre>";