Core database abstraction module for the Tina4 PHP framework, providing the DataBase interface, DataBaseCore trait, DataResult, DataRecord, DataError, and the NoSQLParser for MongoDB support.
composer require tina4stack/tina4php-database- PHP >= 8.1
- ext-json
- tina4stack/tina4php-debug ^2.0
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
}$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;
}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']]]composer testMIT - see LICENSE
Sponsored with 🩵 by Code Infinity
Supporting open source communities • Innovate • Code • Empower
