PHP code example of splitbrain / php-sqlite
1. Go to this page and download the library: Download splitbrain/php-sqlite 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/ */
splitbrain / php-sqlite example snippets
use splitbrain\phpsqlite\SQLite;
// Initialize with database file and schema directory
$db = new SQLite('path/to/database.sqlite', 'path/to/migrations');
// Apply any pending migrations
$db->migrate();
// Query data
$contacts = $db->queryAll("SELECT * FROM contacts WHERE name LIKE ?", "%John%");
// Get a single record
$contact = $db->queryRecord("SELECT * FROM contacts WHERE contact_id = ?", 42);
// Get a single value
$count = $db->queryValue("SELECT COUNT(*) FROM contacts");
// Insert or update data
$newContact = $db->saveRecord("contacts", [
"name" => "John Doe",
"email" => "[email protected]"
]);
// Execute statements
$db->exec("DELETE FROM contacts WHERE contact_id = ?", 42);
bash
composer