note 119892 modified in sqlite3result.finalize by pollita
| From: | pollita@php.net | Date: | Wed, 22 Nov 2017 16:55:15 +0000 |
| Subject: | note 119892 modified in sqlite3result.finalize by pollita | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-209198@lists.php.net to get a copy of this message | ||
A simple example using finalize().
// Open the database connection
$db = new SQLite3('database.db');
// Prepare a query for execution
$query = $db->prepare('SELECT user_id FROM users WHERE username=:username');
$query->bindValue(':username', $_COOKIE['username'], SQLITE3_TEXT);
// Execute the query
$result = $query->execute();
// Store the result of the query
$id = $result->fetchArray(SQLITE3_NUM)[0];
// Close the result set and database connection
$result->finalize();
$db->close();
Of course you should be more careful and clean your cookie, etc.
--was--
A simple example using finalize().
// Open the database connection
$db = new SQLite3('database.db');
// Prepare a query for execution
$query = $db->prepare('SELECT user_id FROM users WHERE username=:username');
$query->bindValue(':username', $_COOKIE['username'], SQLITE3_TEXT);
// Execute the query
$result = $query->execute();
// Store the result of the query
$id = $result->fetchArray(SQLITE3_NUM)[0];
// Close the result set and database connection
$result->finalize();
$db->close();
Of course you should be more careful and clean your cookie, etc.
http://php.net/manual/en/sqlite3result.finalize.php