mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 05:26:57 +08:00
121 lines
5.7 KiB
HTML
121 lines
5.7 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 an SQLite database and returns an SQLiteDatabase object</title>
|
|
</head>
|
|
<body class="docs"><div id="layout">
|
|
<div id="layout-content"><div id="function.sqlite-factory" class="refentry">
|
|
<div class="refnamediv">
|
|
<h1 class="refname">sqlite_factory</h1>
|
|
<p class="verinfo">(PHP 5 < 5.4.0)</p><p class="refpurpose"><span class="refname">sqlite_factory</span> — <span class="dc-title">Opens an SQLite database and returns an SQLiteDatabase object</span></p>
|
|
|
|
</div>
|
|
|
|
<div class="refsect1 description" id="refsect1-function.sqlite-factory-description">
|
|
<h3 class="title">说明</h3>
|
|
<div class="methodsynopsis dc-description">
|
|
<span class="methodname"><strong>sqlite_factory</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"><span class="type SQLiteDatabase">SQLiteDatabase</span></span></div>
|
|
|
|
<p class="para rdfs-comment">
|
|
<span class="function"><strong>sqlite_factory()</strong></span> behaves similarly to
|
|
<span class="function"><a href="sqlite_open.html" class="function">sqlite_open()</a></span> in that it opens an SQLite database or
|
|
attempts to create it if it does not exist. However, a
|
|
<a href="ref.sqlite.html#sqlite.class.sqlitedatabase" class="link">SQLiteDatabase</a> object is
|
|
returned rather than a resource. Please see the
|
|
<span class="function"><a href="sqlite_open.html" class="function">sqlite_open()</a></span> reference page for further usage and caveats.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 parameters" id="refsect1-function.sqlite-factory-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.
|
|
</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-factory-returnvalues">
|
|
<h3 class="title">返回值</h3>
|
|
<p class="para">
|
|
Returns an SQLiteDatabase object on success, <strong><code>NULL</code></strong> on error.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 examples" id="refsect1-function.sqlite-factory-examples">
|
|
<h3 class="title">范例</h3>
|
|
<p class="para">
|
|
<div class="example" id="example-2535">
|
|
<p><strong>Example #1 <span class="function"><strong>sqlite_factory()</strong></span> example</strong></p>
|
|
<div class="example-contents">
|
|
<div class="phpcode"><pre><span style="color: #000000">
|
|
<span style="color: #0000BB"><?php<br />$dbhandle </span><span style="color: #007700">= </span><span style="color: #0000BB">sqlite_factory</span><span style="color: #007700">(</span><span style="color: #DD0000">'sqlitedb'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$dbhandle</span><span style="color: #007700">-></span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">'SELECT user_id, username FROM users'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* functionally equivalent to: */<br /><br /></span><span style="color: #0000BB">$dbhandle </span><span style="color: #007700">= new </span><span style="color: #0000BB">SQLiteDatabase</span><span style="color: #007700">(</span><span style="color: #DD0000">'sqlitedb'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$dbhandle</span><span style="color: #007700">-></span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">'SELECT user_id, username FROM users'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?></span>
|
|
</span>
|
|
</pre></div>
|
|
</div>
|
|
|
|
</div>
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 seealso" id="refsect1-function.sqlite-factory-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_popen.html" class="function" rel="rdfs-seeAlso">sqlite_popen()</a> - Opens a persistent handle to an SQLite database and create the database if it does not exist</span></li>
|
|
</ul>
|
|
</p>
|
|
</div>
|
|
|
|
</div></div></div></body></html> |