PHP code example of tina4stack / tina4php-database

1. Go to this page and download the library: Download tina4stack/tina4php-database 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/ */

    

tina4stack / tina4php-database example snippets


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']]]