mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 05:26:57 +08:00
133 lines
5.3 KiB
HTML
133 lines
5.3 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
|
<title>Opens a persistent handle to an SQLite database and create the database if it does not exist</title>
|
|
</head>
|
|
<body class="docs"><div id="layout">
|
|
<div id="layout-content"><div id="function.sqlite-popen" class="refentry">
|
|
<div class="refnamediv">
|
|
<h1 class="refname">sqlite_popen</h1>
|
|
<p class="verinfo">(PHP 5 < 5.4.0, PECL sqlite >= 1.0.0)</p><p class="refpurpose"><span class="refname">sqlite_popen</span> — <span class="dc-title">
|
|
Opens a persistent handle to an SQLite database and create the database if it does not exist
|
|
</span></p>
|
|
|
|
</div>
|
|
|
|
<div class="refsect1 description" id="refsect1-function.sqlite-popen-description">
|
|
<h3 class="title">说明</h3>
|
|
<div class="methodsynopsis dc-description">
|
|
<span class="methodname"><strong>sqlite_popen</strong></span>
|
|
( <span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span>
|
|
[, <span class="methodparam"><span class="type">int</span> <code class="parameter">$mode</code><span class="initializer"> = 0666</span></span>
|
|
[, <span class="methodparam"><span class="type">string</span> <code class="parameter reference">&$error_message</code></span>
|
|
]] ) : <span class="type">resource</span></div>
|
|
|
|
<p class="simpara">
|
|
This function behaves identically to <span class="function"><a href="sqlite_open.html" class="function">sqlite_open()</a></span>
|
|
except that is uses the persistent resource mechanism of PHP.
|
|
For information about the meaning of the parameters, read the
|
|
<span class="function"><a href="sqlite_open.html" class="function">sqlite_open()</a></span> manual page.
|
|
</p>
|
|
<p class="para">
|
|
<span class="function"><strong>sqlite_popen()</strong></span> will first check to see if a persistent
|
|
handle has already been opened for the given
|
|
<code class="parameter">filename</code>. If it finds one, it returns that handle
|
|
to your script, otherwise it opens a fresh handle to the database.
|
|
</p>
|
|
<p class="para">
|
|
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).
|
|
</p>
|
|
<blockquote class="note"><p><strong class="note">Note</strong>:
|
|
<span class="simpara">
|
|
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.
|
|
</span>
|
|
<span class="simpara">
|
|
To avoid this situation, have your background processes open the same
|
|
database file and perform their updates in a transaction.
|
|
</span>
|
|
</p></blockquote>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 parameters" id="refsect1-function.sqlite-popen-parameters">
|
|
<h3 class="title">参数</h3>
|
|
<p class="para">
|
|
<dl>
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">filename</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
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.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">mode</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
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
|
|
<em>0666</em> and this is the recommended value.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">error_message</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
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.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
</dl>
|
|
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 returnvalues" id="refsect1-function.sqlite-popen-returnvalues">
|
|
<h3 class="title">返回值</h3>
|
|
<p class="para">
|
|
Returns a resource (database handle) on success, <strong><code>FALSE</code></strong> on error.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 seealso" id="refsect1-function.sqlite-popen-seealso">
|
|
<h3 class="title">参见</h3>
|
|
<p class="para">
|
|
<ul class="simplelist">
|
|
<li class="member"><span class="function"><a href="sqlite_open.html" class="function" rel="rdfs-seeAlso">sqlite_open()</a> - Opens an SQLite database and create the database if it does not exist</span></li>
|
|
<li class="member"><span class="function"><a href="sqlite_close.html" class="function" rel="rdfs-seeAlso">sqlite_close()</a> - Closes an open SQLite database</span></li>
|
|
<li class="member"><span class="function"><a href="sqlite_factory.html" class="function" rel="rdfs-seeAlso">sqlite_factory()</a> - Opens an SQLite database and returns an SQLiteDatabase object</span></li>
|
|
</ul>
|
|
</p>
|
|
</div>
|
|
|
|
</div></div></div></body></html> |