1. Go to this page and download the library: Download joshmcrae/squeal 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/ */
joshmcrae / squeal example snippets
use Squeal\Database;
// File
$db = Database::fromFile('path/to/database.db');
// In-memory (useful for testing or long-running processes)
$db = Database::inMemory();
// Positional parameters
$db->exec('select * from users where id = ?', ['123']);
// Named parameters
$db->exec('select * from users where id = :id', ['id' => '123']);
$db->exec('
select *
from users
where active = 1
[[and type = :type]]
[[and created_at < :hour_ago]]
', [
'hour_ago' => time() - 3600
]);
// select * from users where active = 1 and created_at < :hour_ago
$results = $db->exec('select * from users');
// Fetch a single record
$results->one();
// Fetch remaining records
$results->all();
// Map remaining records through transformer function
$users = $results->map(fn (array $row) => new User($row['id'], $row['email'], $row['name']));
$dir = $db->directory('reports', '.sql');
// List available queries by name
$queries = $dir->list();
// Execute a query by name
$result = $dir->exec('outstanding_orders', [':as_of' => time()]);
// Use the directory for migrations
$migrated = $dir
->asMigrations() // automatically tracks versions
->up(); // applies only pending versions
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.