mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 05:26:57 +08:00
119 lines
6.8 KiB
HTML
119 lines
6.8 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>Fetches the first column of a result set as a string</title>
|
||
</head>
|
||
<body class="docs"><div id="layout">
|
||
<div id="layout-content"><div id="function.sqlite-fetch-single" class="refentry">
|
||
<div class="refnamediv">
|
||
<h1 class="refname">sqlite_fetch_single</h1>
|
||
<h1 class="refname">SQLiteResult::fetchSingle</h1>
|
||
<h1 class="refname">SQLiteUnbuffered::fetchSingle</h1>
|
||
<p class="verinfo">(PHP 5 < 5.4.0, PECL sqlite >= 1.0.1)</p><p class="refpurpose"><span class="refname">sqlite_fetch_single</span> -- <span class="refname">SQLiteResult::fetchSingle</span> -- <span class="refname">SQLiteUnbuffered::fetchSingle</span> — <span class="dc-title">Fetches the first column of a result set as a string</span></p>
|
||
|
||
</div>
|
||
|
||
<div class="refsect1 description" id="refsect1-function.sqlite-fetch-single-description">
|
||
<h3 class="title">说明</h3>
|
||
<div class="methodsynopsis dc-description">
|
||
<span class="methodname"><strong>sqlite_fetch_single</strong></span>
|
||
( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$result</code></span>
|
||
[, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$decode_binary</code><span class="initializer"> = <strong><code>TRUE</code></strong></span></span>
|
||
] ) : <span class="type">string</span></div>
|
||
|
||
<p class="para rdfs-comment">面向对象风格 (method):</p>
|
||
<div class="methodsynopsis dc-description">
|
||
<span class="methodname"><strong>SQLiteResult::fetchSingle</strong></span>
|
||
([ <span class="methodparam"><span class="type">bool</span> <code class="parameter">$decode_binary</code><span class="initializer"> = <strong><code>TRUE</code></strong></span></span>
|
||
] ) : <span class="type">string</span></div>
|
||
|
||
<div class="methodsynopsis dc-description">
|
||
<span class="methodname"><strong>SQLiteUnbuffered::fetchSingle</strong></span>
|
||
([ <span class="methodparam"><span class="type">bool</span> <code class="parameter">$decode_binary</code><span class="initializer"> = <strong><code>TRUE</code></strong></span></span>
|
||
] ) : <span class="type">string</span></div>
|
||
|
||
<p class="para rdfs-comment">
|
||
<span class="function"><strong>sqlite_fetch_single()</strong></span> is identical to
|
||
<span class="function"><a href="sqlite_fetch_array.html" class="function">sqlite_fetch_array()</a></span> except that it returns the value
|
||
of the first column of the rowset.
|
||
</p>
|
||
<p class="para">
|
||
This is the most optimal way to retrieve data when you are only
|
||
interested in the values from a single column of data.
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 parameters" id="refsect1-function.sqlite-fetch-single-parameters">
|
||
<h3 class="title">参数</h3>
|
||
<p class="para">
|
||
<dl>
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">result</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
The SQLite result resource. This parameter is not required when using
|
||
the object-oriented method.
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">decode_binary</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">当
|
||
<code class="parameter">decode_binary</code> 参数设置为 <strong><code>TRUE</code></strong>(默认值)时,PHP 会解码那些由
|
||
<span class="function"><a href="sqlite_escape_string.html" class="function">sqlite_escape_string()</a></span>
|
||
编码后的二进制数据。通常应保留此值为其默认值,除非要与其他使用 SQLlite 的应用程序建立的数据交互。</p>
|
||
</dd>
|
||
|
||
|
||
</dl>
|
||
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 returnvalues" id="refsect1-function.sqlite-fetch-single-returnvalues">
|
||
<h3 class="title">返回值</h3>
|
||
<p class="para">
|
||
Returns the first column value, as a string.
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 examples" id="refsect1-function.sqlite-fetch-single-examples">
|
||
<h3 class="title">范例</h3>
|
||
<p class="para">
|
||
<div class="example" id="example-2542">
|
||
<p><strong>Example #1 A <span class="function"><strong>sqlite_fetch_single()</strong></span> example</strong></p>
|
||
<div class="example-contents">
|
||
<div class="phpcode"><pre><span style="color: #000000">
|
||
<span style="color: #0000BB"><?php<br /></span><span style="color: #007700">if (</span><span style="color: #0000BB">$dbhandle </span><span style="color: #007700">= </span><span style="color: #0000BB">sqlite_open</span><span style="color: #007700">(</span><span style="color: #DD0000">'mysqlitedb'</span><span style="color: #007700">, </span><span style="color: #0000BB">0666</span><span style="color: #007700">, </span><span style="color: #0000BB">$sqliteerror</span><span style="color: #007700">)) {<br /><br /> </span><span style="color: #0000BB">$sql </span><span style="color: #007700">= </span><span style="color: #DD0000">"SELECT id FROM sometable WHERE id = 42"</span><span style="color: #007700">;<br /> </span><span style="color: #0000BB">$res </span><span style="color: #007700">= </span><span style="color: #0000BB">sqlite_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbhandle</span><span style="color: #007700">, </span><span style="color: #0000BB">$sql</span><span style="color: #007700">);<br /><br /> if (</span><span style="color: #0000BB">sqlite_num_rows</span><span style="color: #007700">(</span><span style="color: #0000BB">$res</span><span style="color: #007700">) > </span><span style="color: #0000BB">0</span><span style="color: #007700">) {<br /> echo </span><span style="color: #0000BB">sqlite_fetch_single</span><span style="color: #007700">(</span><span style="color: #0000BB">$res</span><span style="color: #007700">); </span><span style="color: #FF8000">// 42<br /> </span><span style="color: #007700">}<br /> <br /> </span><span style="color: #0000BB">sqlite_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbhandle</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-fetch-single-seealso">
|
||
<h3 class="title">参见</h3>
|
||
<p class="para">
|
||
<ul class="simplelist">
|
||
<li class="member"><span class="function"><a href="sqlite_fetch_array.html" class="function" rel="rdfs-seeAlso">sqlite_fetch_array()</a> - Fetches the next row from a result set as an array</span></li>
|
||
</ul>
|
||
</p>
|
||
</div>
|
||
|
||
</div></div></div></body></html> |