tina4stack/tina4php-database

Tina4 PHP Database Module

Maintainers

Package info

github.com/tina4stack/tina4php-database

pkg:composer/tina4stack/tina4php-database

Statistics

Installs: 7 234

Dependents: 14

Suggesters: 1

Stars: 2

Open Issues: 0

v2.0.24 2026-03-14 19:28 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

Code Infinity

Supporting open source communities • Innovate • Code • Empower