Connecting to SQLite in PHP is a straightforward process. You'll need to use the SQLite3 class provided by PHP to open a database file and execute SQL commands. Here's a simple example of how to do this:
<?php
// Create (or open) the database
$db = new SQLite3('example.db');
// Create a table
$db->exec("CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT)");
// Insert data into the table
$db->exec("INSERT INTO users (name) VALUES ('John Doe')");
// Query the database
$results = $db->query('SELECT * FROM users');
while ($row = $results->fetchArray()) {
echo $row['name'] . '<br>';
}
// Close the database connection
$db->close();
?>
How do I avoid rehashing overhead with std::set in multithreaded code?
How do I find elements with custom comparators with std::set for embedded targets?
How do I erase elements while iterating with std::set for embedded targets?
How do I provide stable iteration order with std::unordered_map for large datasets?
How do I reserve capacity ahead of time with std::unordered_map for large datasets?
How do I erase elements while iterating with std::unordered_map in multithreaded code?
How do I provide stable iteration order with std::map for embedded targets?
How do I provide stable iteration order with std::map in multithreaded code?
How do I avoid rehashing overhead with std::map in performance-sensitive code?
How do I merge two containers efficiently with std::map for embedded targets?