A single-file PHP database framework.

Write SQL with a compact query builder or bound raw queries. One PHP file, PDO, and no runtime dependencies beyond your database driver.

Release v0.3.1 CI status PHP 8.1 or newer MIT license

Quick start

Download DBF.php into your project. This SQLite example creates its own in-memory table.

<?php
require __DIR__ . '/DBF.php';

$db = new ndtan\DBF('sqlite::memory:');
$db->execute('CREATE TABLE users (
    id INTEGER PRIMARY KEY, email TEXT UNIQUE, status TEXT
)');
$db->table('users')->insert([
    'email' => 'hello@ndtan.net',
    'status' => 'active',
]);

$users = $db->table('users')
    ->select(['id', 'email'])
    ->where('status', '=', 'active')
    ->orderBy('id', 'asc')
    ->get();

Prefer Composer? composer require ndtan/dbf:0.3.1, then load vendor/autoload.php.

Explore the documentation

Connect your database
PDO, DSN and URI configuration; read and write routing.
Build a query
Conditions, joins, aggregates and pagination.
Work with transactions
Writer pinning, retries and nested savepoints.
Query and update JSON
JSON paths and the supported database dialects.

MySQL/MariaDB, PostgreSQL and SQLite support the core feature set. SQL Server and Oracle support connections and basic pagination; advanced features have explicit driver limits.

Download NDT DBF

DBF.php v0.3.1 · PHP 8.1+

Open DBF.php

Composer

composer require ndtan/dbf:^0.3
Release notes