This maxim holds true for SQLite; once you??™ve completed working
with a database, you should close the open handle. One function, sqlite_close(),
accomplishes just this. Its prototype follows:
void sqlite_close(resource dbh)
You should call this function after all necessary tasks involving the database have been
completed. An example follows:
574 CHAPTER 22 ?– SQLITE
$sqldb = sqlite_open("corporate.db");
// Perform necessary tasks
sqlite_close($sqldb);
?>
Note that if a pending transaction has not been completed at the time of closure,
the transaction will automatically be rolled back.
Querying a Database
The majority of your time spent interacting with a database server takes the form of
SQL queries. The functions sqlite_query() and sqlite_unbuffered_query() offer the
main vehicles for submitting these queries to SQLite and returning the subsequent
result sets. You should pay particular attention to the specific advantages of each
because applying them inappropriately can negatively impact performance and
capabilities.
Executing a SQL Query
The sqlite_query() function executes a SQL query against the database. Its prototype
follows:
resource sqlite_query(resource dbh, string query [, int result_type
[, string &error_msg]])
If the query is intended to return a result set, FALSE is returned if the query fails. All
other queries return TRUE if the query is successful.
Pages:
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659