sqlite_popen

(PHP 5 < 5.4.0, PECL sqlite >= 1.0.0)

sqlite_popen Opens a persistent handle to an SQLite database and create the database if it does not exist

说明

sqlite_popen ( string $filename [, int $mode = 0666 [, string &$error_message ]] ) : resource

This function behaves identically to sqlite_open() except that is uses the persistent resource mechanism of PHP. For information about the meaning of the parameters, read the sqlite_open() manual page.

sqlite_popen() will first check to see if a persistent handle has already been opened for the given filename. If it finds one, it returns that handle to your script, otherwise it opens a fresh handle to the database.

The benefit of this approach is that you don't incur the performance cost of re-reading the database and index schema on each page hit served by persistent web server SAPI's (any SAPI except for regular CGI or CLI).

Note: If you use persistent handles and have the database updated by a background process (perhaps via a crontab), and that process re-creates the database by overwriting it (either by unlinking and rebuilding, or moving the updated version to replace the current version), you may experience undefined behaviour when a persistent handle on the old version of the database is recycled. To avoid this situation, have your background processes open the same database file and perform their updates in a transaction.

参数

filename

The filename of the SQLite database. If the file does not exist, SQLite will attempt to create it. PHP must have write permissions to the file if data is inserted, the database schema is modified or to create the database if it does not exist.

mode

The mode of the file. Intended to be used to open the database in read-only mode. Presently, this parameter is ignored by the sqlite library. The default value for mode is the octal value 0666 and this is the recommended value.

error_message

Passed by reference and is set to hold a descriptive error message explaining why the database could not be opened if there was an error.

返回值

Returns a resource (database handle) on success, FALSE on error.

参见

  • sqlite_open() - Opens an SQLite database and create the database if it does not exist
  • sqlite_close() - Closes an open SQLite database
  • sqlite_factory() - Opens an SQLite database and returns an SQLiteDatabase object

相关文章
php direct io 函数 opens a file creating it if necessary at a lower level than the c library input/ouput stream functions allowphp frontbase 函数 create a frontbase databasephp ingres 函数 open a persistent connection to an ingres databasephp mcve 函数 whether or not to validate the passed identifier on any transaction it is passed tophp ncurses 函数 remove panel from the stack and delete it but not the associated window php paradox 函数 create a new paradox databasephp sqlite 函数 executes a result less query against a given databasephp sqlite 函数 opens an sqlite database and returns an sqlitedatabase objectphp sqlite 函数 returns the error code of the last error for a databasephp sqlite 函数 opens an sqlite database and create the database if it does not existphp sqlite 函数 opens a persistent handle to an sqlite database and create the database if it does not existphp sqlite 函数 executes a query against a given database and returns a result handlephp sqlite 函数 execute a query that does not prefetch and buffer all dataphp wincache 函数 adds a variable in user cache only if variable does not already exist in the cachephp wincache 函数 adds a variable in user cache and overwrites a variable if it already exists in the cachephp mongocollection creates an index on the specified field s if it does not already existphp mongocollection creates an index on the specified field s if it does not already existphp mongocommandcursor checks if there are results that have not yet been sent from the databasephp mongocursor checks if there are results that have not yet been sent from the databasephp swoole lock try to acquire the lock. it will block if the lock is not available.
关注编程学问公众号