1. Go to this page and download the library: Download ndtan/dbf 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/ */
ndtan / dbf example snippets
ndtan\DBF;
$db = new DBF('sqlite::memory:');
$db->execute('CREATE TABLE users (id INTEGER PRIMARY KEY, email TEXT UNIQUE, status TEXT)');
$id = $db->tx(function (DBF $tx): int {
return $tx->table('users')->insert([
'email' => '[email protected]',
'status' => 'active',
]);
});
$user = $db->table('users')
->select(['id', 'email'])
->where('id', '=', $id)
->first();
echo $user['email']; // [email protected]
$db = new ndtan\DBF('sqlite::memory:');
$db = new ndtan\DBF('mysql://user:[email protected]/app?charset=utf8mb4');
$rows = $db->selectRaw('SELECT email FROM users WHERE id = :id', ['id' => 1]);
$affected = $db->execute('UPDATE users SET status = ? WHERE id = ?', ['vip', 1]);
$result = $db->raw('INSERT INTO users(email) VALUES (?) RETURNING id', ['[email protected]']);