1. Go to this page and download the library: Download biohzrdmx/datum-php 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/ */
$options = [
'file' => 'path/to/database.sqlite'
];
$adapter = new SQLiteAdapter($options);
$database = new Database($adapter);
$database->query("CREATE TABLE test ...");
$database->query("DROP TABLE IF EXISTS test");
$database->query("INSERT INTO ...");
$id = $database->lastInsertId();
$params = [4];
$row = $database->query("SELECT * FROM test WHERE id = ?", $params, function($stmt) {
return $stmt->fetch();
});
$rows = $database->select("SELECT * FROM test");
$params = ['Draft'];
$rows = $database->select("SELECT * FROM test WHERE status = ?", $params);
$params = ['status' => 'Draft'];
$rows = $database->select("SELECT * FROM test WHERE status = :status", $params);
$params = ['id' => 2];
$row = $database->first("SELECT * FROM test WHERE id = :id", $params);
$count = $database->scalar("SELECT count(*) FROM test");
$params = ['Published'];
$database->chunk(100, "SELECT id, title FROM test WHERE status = ?", $params, function($rows) {
foreach ($rows as $row) {
// Do something with the row data
}
});
$database->transaction(function($database) {
$params = ['Draft', 2];
$database->query("UPDATE test SET status = ? WHERE id = ?", $params);
});
$params = ['Published', 3];
try {
$database->begin();
$database->query("UPDATE test SET status = ? WHERE id = ?", $params);
$database->commit();
} catch (Exception $e) {
$database->rollback();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.