PHP code example of keiii / pdo-wrapper
1. Go to this page and download the library: Download keiii/pdo-wrapper 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/ */
keiii / pdo-wrapper example snippets
use KEIII\PdoWrapper\PdoWrapper;
use KEIII\PdoWrapper\PdoQuery;
$db = new PdoWrapper('sqlite::memory:');
// write
$sql = 'INSERT INTO people (name) VALUES (:name);';
$parameters = [':name' => 'John'];
$db->write(new PdoQuery($sql, $parameters));
// read one
$sql = 'SELECT * FROM people WHERE name = :name;';
$parameters = [':name' => 'John'];
$john = $db->read(new PdoQuery($sql, $parameters))->getFirst();
// as generator
$sql = 'SELECT * FROM people;';
$people = $db->read(new PdoQuery($sql))->asGenerator();
foreach ($people as $human) {
// ...
}