1. Go to this page and download the library: Download progrmanial/simplemdb 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/ */
progrmanial / simplemdb example snippets
SimpleMDB\DatabaseFactory;
use SimpleMDB\SchemaBuilder;
// Connect to MySQL database
$db = DatabaseFactory::create('pdo', 'localhost', 'root', 'password', 'myapp');
// Create modern table with enterprise features
$schema = new SchemaBuilder($db);
$schema->increments('id') // Auto-increment primary key
->string('name', 100)->comment('Full name') // VARCHAR with comment
->string('email', 150)->unique() // Unique email
->boolean('is_active')->default(true) // Boolean with default
->json('preferences')->nullable() // JSON data storage
->ipAddress('last_login_ip')->nullable() // IPv4/IPv6 address
->timestamps() // created_at, updated_at
->createTable('users');
echo "✅ Modern users table created!\n";
SimpleMDB\DatabaseFactory;
use SimpleMDB\SchemaBuilder_PostgreSQL;
// Connect to PostgreSQL database
$db = DatabaseFactory::create('postgresql', 'localhost', 'postgres', 'password', 'myapp');
// Create modern table with PostgreSQL-specific features
$schema = new SchemaBuilder_PostgreSQL($db);
$schema->increments('id') // SERIAL PRIMARY KEY
->string('name', 100)->comment('Full name') // VARCHAR with comment
->string('email', 150)->unique() // Unique email
->boolean('is_active')->default(true) // Boolean with default
->jsonb('preferences')->nullable() // JSONB data storage (PostgreSQL)
->inet('last_login_ip')->nullable() // INET address type (PostgreSQL)
->uuidWithDefault('external_id') // UUID with gen_random_uuid()
->textArray('tags')->nullable() // TEXT[] array (PostgreSQL)
->timestamps() // created_at, updated_at
->createTable('users');
echo "✅ Modern PostgreSQL users table created!\n";
use SimpleMDB\Backup\BackupManager;
$backupManager = new BackupManager($db, 'backups/');
// Memory-efficient encrypted backup
$backup = $backupManager
->backup('daily_backup')
->streaming(1000) // Process in chunks
->encrypted($encryptionKey) // AES-256 encryption
->compress('gzip') // Space efficient
->execute();
use SimpleMDB\DatabaseObjects\DatabaseObjectManager;
$objects = new DatabaseObjectManager($db);
// Create a function
$objects->function('calculate_total')
->inParameter('amount', 'DECIMAL(10,2)')
->returns('DECIMAL(10,2)')
->body("RETURN amount * 1.1;")
->create();
// Create a view with complex logic
$objects->view('user_summary')
->select("
u.id, u.name, u.email,
COUNT(o.id) as order_count,
SUM(o.total) as total_spent
FROM users u
LEFT JOIN orders o ON u.id = o.user_id
GROUP BY u.id
")
->create();
// Create a trigger for auditing
$objects->trigger('audit_changes')
->after()
->update()
->on('users')
->body("INSERT INTO audit_log (table_name, action, record_id) VALUES ('users', 'UPDATE', NEW.id);")
->create();