1. Go to this page and download the library: Download wherd/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/ */
wherd / database example snippets
use Wherd\Database\Connection;
use Wherd\Database\Fetch;
$db = new Connection('sqlite::memory:');
$db->prepare('CREATE TABLE users (username TEXT, email TEXT, password TEXT)')->execute();
$stmt = $db->prepare('INSERT INTO users (username, email, password) VALUES (?, ?, ?)');
$stmt->execute('wherd', '[email protected]', '*****');
// Can allso invoke execute method directly
// $stmt('wherd', '[email protected]', '*****');
$users = $db
->prepare('SELECT username, email FROM users')
->as(Fetch::KeyValuePair)
->fetchAll() // Optional - Statement is traversables
;
foreach ($users as $username => $email) {
echo $username, ' - ', $email;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.