1. Go to this page and download the library: Download alexoliverwd/basic-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/ */
alexoliverwd / basic-sqlite example snippets
use AOWD\SQLite;
$db_location = __DIR__ . '/example.sqlite';
$db = new SQLite($db_location);
// Import the SQLite Helper Class
use AOWD\SQLite;
use AOWD\DataType;
// Create a New SQLite Database Instance
$db = new SQLite(__DIR__ . '/users.sqlite3');
// Set the Target Table
$table = 'users';
$db->setTableName($table);
// Register Columns for the Table
$db->registerColumn('first_name', DataType::TEXT);
$db->registerColumn('last_name', DataType::TEXT);
$db->registerColumn('uuid', DataType::TEXT, false, true, true);
// Create the Table Schema
$db->migrate();
// Insert a Record Using a Prepared Statement
$query = <<<QUERY
INSERT INTO `$table` (`first_name`, `last_name`, `uuid`) VALUES (?, ?, ?)
QUERY;
$db->query($query, false, [
[
1,
'some firstname',
SQLITE3_TEXT
],
[
2,
'some lastname',
SQLITE3_TEXT
],
[
3,
uniqid('uuid' . time(), true),
SQLITE3_TEXT
]
]);
// Count Records in the Table
$count = $db->query("SELECT count() AS 'record_count' FROM `$table`");
echo "$count[0][record_count] record(s)";
// Close the Database Connection
$db->close();
$db = new SQLite('/path/to/database.sqlite', [
'cache_size' => 10000
]);
// Register a column named 'username' with a TEXT type, non-nullable, and unique constraint
$database->registerColumn(
column_name: 'username',
type: DataType::TEXT,
can_be_null: false,
is_post_