PHP code example of tueen / database

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

    

tueen / database example snippets


use Tueen\Database\Config\DatabaseConfig;
use Tueen\Database\DatabaseManager;

// Initialize with zero-config auto-migration (SQLite file or :memory:)
$db = DatabaseManager::create(DatabaseConfig::createSqlite(':memory:'));

// 1. Find or create a Telegram user
$chat = $db->chats()->findOrCreate(
    chatId: 123456789,
    username: '@telegram_user',
    name: 'Alice',
);

// 2. Perform atomic wallet credit
$tx = $db->wallets()->credit($chat, '50.000000000000000000', 'TON', 'welcome_bonus');

// 3. Store global bot options and configuration
$db->options()->set('maintenance_mode', false, 'system');
bash
# Verify schema & entity mappings
php bin/tueen-db tueen:db:validate

# Inspect engine status
php bin/tueen-db tueen:db:status

# Synchronize schema diffs
php bin/tueen-db tueen:db:sync

# Clear caches
php bin/tueen-db tueen:cache:clear