PHP code example of kiss-php / tables

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

    

kiss-php / tables example snippets


$_ENV['DB_TYPE'] = 'sqlite';
$_ENV['DB_PATH'] = __DIR__ . '/db/app.sqlite';

$_ENV['DB_TYPE'] = 'mysql';
$_ENV['DB_HOST'] = 'localhost';
$_ENV['DB_USER'] = 'root';
$_ENV['DB_PASS'] = '';
$_ENV['DB_DTBS'] = 'app';
$_ENV['DB_PORT'] = '3306';



use Kiss\Tables\TablesManager;

TablesManager::setFolder(__DIR__ . '/Tables');
TablesManager::ensureSchema();

$user = TablesManager::new('User');
$user->setUser('ada');
$user->setMail('[email protected]');
$user->persist();

$found = TablesManager::getOne('User', ['user' => 'ada']);
$found->setMail('[email protected]');
$found->persist();

$user->setMailVerified(true); // mail_verified
$user->getMailVerified();

TablesManager::setAutoRepair(false);

TablesManager::ensureSchema();

TablesManager::rollback();

use Kiss\Tables\History;

History::callback(function (array $entry) {
    // Send to Monolog, a PSR-3 logger, stdout, a file, etc.
    // $entry contains: type, message, context.
    // Redact or drop sensitive values here if your app needs it.
});
bash
composer dump-autoload
bash
php tests/smoke.php