tina4stack / tina4php-database
Tina4 PHP Database Module
v2.0.24
2026-03-14 19:28 UTC
Requires
- php: >=8.1
- ext-json: *
- tina4stack/tina4php-debug: ^2.0
Requires (Dev)
- overtrue/phplint: ^2.0
- phpunit/phpunit: ^9
- roave/security-advisories: dev-latest
This package is auto-updated.
Last update: 2026-03-14 19:35:33 UTC
README
Core database abstraction module for the Tina4 PHP framework, providing the DataBase interface, DataBaseCore trait, DataResult, DataRecord, DataError, and the NoSQLParser for MongoDB support.
Installation
composer require tina4stack/tina4php-database
Requirements
- PHP >= 8.1
- ext-json
- tina4stack/tina4php-debug ^2.0
Usage
Implementing a Custom Database Driver
use Tina4\DataBase; use Tina4\DataBaseCore; class DataMyDb implements DataBase { use DataBaseCore; public function open() { /* open connection */ } public function close() { /* close connection */ } public function exec() { /* execute statement */ } // ... implement remaining interface methods }
Running a Query
$db = new DataMyDb("localhost/3306:mydb", "user", "password"); $result = $db->fetch("SELECT * FROM users WHERE active = 1"); foreach ($result->records() as $record) { echo $record->name; }
Using the NoSQL Parser
use Tina4\NoSQLParser; $parser = new NoSQLParser(); $parsed = $parser->parseSQLToNoSQL("select id, name from users where id = 1"); // Returns: ["collectionName" => "users", "columns" => ["id", "name"], "filter" => ["id" => ['$eq' => '1']]]
Testing
composer test
License
MIT - see LICENSE
Our Sponsors
Sponsored with 🩵 by Code Infinity
Supporting open source communities • Innovate • Code • Empower