User Tools

Site Tools


snippets:php

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
snippets:php [2025-06-26 13:35] – Abschnitt mit Links zu gist.github.com hinzugefügt malte70snippets:php [2025-11-10 15:56] (current) – [SQLite3] Quellcode-Kommentare malte70
Line 35: Line 35:
  
 echo "\$mail_sent = " . ($mail_sent ? "True" : "False") . "\n;" echo "\$mail_sent = " . ($mail_sent ? "True" : "False") . "\n;"
 +
 +</file>
 +
 +===== SQLite3 =====
 +
 +  * [[https://www.php.net/manual/en/class.sqlite3.php|PHP: SQLite3 - Manual]]
 +  * [[https://www.php.net/manual/en/class.sqlite3stmt.php|PHP: SQLite3Stmt - Manual]]
 +  * [[https://www.php.net/manual/en/class.sqlite3result.php|PHP: SQLite3Result - Manual]]
 +
 +<file php sqlite3.php>
 +<?php
 +// Open database and create it if necessary
 +$db = new SQLite3("dbfile.sqlite3");
 +
 +// Initialize the database with a table and some data
 +$db->exec('CREATE TABLE users(id INT NOT NULL PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, email TEXT DEFAULT NULL, password TEXT NOT NULL');
 +$db->exec('INSERT INTO users (name, email, password) VALUES ("john.doe", "john.doe@example.com", "1234"));');
 +$db->exec('INSERT INTO users (name, email, password) VALUES ("jane.doe", "jane.doe@example.com", "asdf"));');
 +
 +// Create a SQLite3Stmt, bind some values and execute the SQL command safely
 +$stmt = $db->prepare('SELECT * FROM users WHERE id=:id AND name=:name');
 +$stmt->bindValue(':id', 1, SQLITE3_INTEGER);
 +$stmt->bindValue(':name', "john.doe", SQLITE3_TEXT);
 +
 +// Execute statement and get first row as an associative Array
 +$res = $stmt->execute();
 +var_dump($res->fetchArray());
  
 </file> </file>
  
  
snippets/php.1750944906.txt.gz · Last modified: by malte70