1. Go to this page and download the library: Download skim/framework 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/ */
// %placeholders% are removed silently if their keys are absent — no string concatenation needed
Db::all('SELECT * FROM users %where% %limit%', [
'where' => ['status = :status'],
':status' => 'active',
'limit' => 20,
]);
Db::row('SELECT * FROM users WHERE id = :id', [':id' => 5]);
Db::val('SELECT COUNT(*) FROM users');
Db::transaction(function() {
Db::query('UPDATE accounts %set% WHERE id = :id', ['set' => ['balance' => 100], ':id' => 1]);
Db::query('UPDATE accounts %set% WHERE id = :id', ['set' => ['balance' => 200], ':id' => 2]);
});
class User extends \Skim\Db\Model {
protected static string $table = 'users';
protected static array $guarded = ['id', 'created_at'];
protected static array $casts = ['age' => 'int', 'is_active' => 'bool'];
}
User::find(1); // Model|null
User::findOrFail(1); // Model|NotFoundException
User::where(['status' => 'active'])->limit(10)->all();
User::create(['name' => 'John', 'email' => '[email protected]']);
$user->name = 'Jane';
$user->save(); // INSERT if no id, UPDATE only changed columns if id set
$user->delete();
// config/db.php — add as many named connections as needed
'alt' => [
'driver' => 'pgsql',
'host' => env('ALT_DB_HOST', 'pgsql'),
// ...
];
// Use the connection name on any query
Db::all('SELECT * FROM reports', [], connection: 'alt');
Cache::set('user:1', $user, 3600);
Cache::get('user:1');
Cache::remember('user:1', 3600, fn() => User::find(1)); // get or compute+cache
Cache::delete('user:1');
Cache::flush('user:'); // remove all keys starting with 'user:'
Cache::tags(['users'])->flush(); // Redis only — tag-scoped invalidation