1. Go to this page and download the library: Download felixkiss/database 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/ */
felixkiss / database example snippets
use Felixkiss\Database\Database;
$pdo = new PDO('mysql:dbname=foo;host=127.0.0.1', 'foo', 'bar');
$db = new Database($pdo);
$db->execute('TRUNCATE some_table');
$user = $db->select('SELECT * FROM user');
foreach ($users as $user)
{
// Do something ...
}
$users = $db->select('SELECT * FROM user WHERE age BETWEEN ? AND ?', [20, 40]);
$users = $db->select(
'SELECT * FROM user WHERE age BETWEEN :young AND :old LIMIT 0, :limit', [
':young' => 20,
':old' => 40,
':limit' => 10,
]);
$users = $db->lists('SELECT username FROM users');
$count = $db->pluck('SELECT COUNT(*) FROM users');