1. Go to this page and download the library: Download darkterminal/libsql-php-ext 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/ */
darkterminal / libsql-php-ext example snippets
use Darkterminal\LibSQLPHPExtension\LibSQLPHP;
connected()) {
echo $db->version() . PHP_EOL;
}
$db->close(); // Always close the database connection
$db->exec("CREATE TABLE users (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT)");
$db->exec("INSERT INTO users (name) VALUES ('Handoko')");
$db->exec("INSERT INTO users (name) VALUES ('Karlina')");
$result = $db->querySingle("SELECT name FROM users WHERE id = 1");
$result2 = $db->querySingle("SELECT name FROM users WHERE id = 2", true);
var_dump($result);
// string(5) "Randi"
var_dump($result2);
// array(1) {
// ["name"]=>
// string(4) "Ando"
// }
echo "Return the column count:" . PHP_EOL;
var_dump($result->numColumns());
echo "Return the column names:" . PHP_EOL;
var_dump($result->columName());
echo "Return the column types:" . PHP_EOL;
var_dump($result->columnType());