mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 13:57:03 +08:00
137 lines
6.8 KiB
HTML
137 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>Returns the name or oid of the tables field</title>
|
|
</head>
|
|
<body class="docs"><div id="layout">
|
|
<div id="layout-content"><div id="function.pg-field-table" class="refentry">
|
|
<div class="refnamediv">
|
|
<h1 class="refname">pg_field_table</h1>
|
|
<p class="verinfo">(PHP 5 >= 5.2.0, PHP 7)</p><p class="refpurpose"><span class="refname">pg_field_table</span> — <span class="dc-title">Returns the name or oid of the tables field</span></p>
|
|
|
|
</div>
|
|
|
|
<div class="refsect1 description" id="refsect1-function.pg-field-table-description">
|
|
<h3 class="title">说明</h3>
|
|
<div class="methodsynopsis dc-description">
|
|
<span class="methodname"><strong>pg_field_table</strong></span>
|
|
( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$result</code></span>
|
|
, <span class="methodparam"><span class="type">int</span> <code class="parameter">$field_number</code></span>
|
|
[, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$oid_only</code><span class="initializer"> = <strong><code>FALSE</code></strong></span></span>
|
|
] ) : <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span></div>
|
|
|
|
<p class="para rdfs-comment">
|
|
<span class="function"><strong>pg_field_table()</strong></span> returns the name of the table that field
|
|
belongs to, or the table's oid if <code class="parameter">oid_only</code> is <strong><code>TRUE</code></strong>.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 parameters" id="refsect1-function.pg-field-table-parameters">
|
|
<h3 class="title">参数</h3>
|
|
<p class="para">
|
|
<dl>
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">result</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
PostgreSQL query result resource, returned by <span class="function"><a href="pg_query.html" class="function">pg_query()</a></span>,
|
|
<span class="function"><a href="pg_query_params.html" class="function">pg_query_params()</a></span> or <span class="function"><a href="pg_execute.html" class="function">pg_execute()</a></span>
|
|
(among others).
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">field_number</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
Field number, starting from 0.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">oid_only</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
By default the tables name that field belongs to is returned but
|
|
if <code class="parameter">oid_only</code> is set to <strong><code>TRUE</code></strong>, then the
|
|
oid will instead be returned.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
</dl>
|
|
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 returnvalues" id="refsect1-function.pg-field-table-returnvalues">
|
|
<h3 class="title">返回值</h3>
|
|
<p class="para">
|
|
On success either the fields table name or oid. Or, <strong><code>FALSE</code></strong> on failure.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 examples" id="refsect1-function.pg-field-table-examples">
|
|
<h3 class="title">范例</h3>
|
|
<p class="para">
|
|
<div class="example" id="example-2495">
|
|
<p><strong>Example #1 Getting table information about a field</strong></p>
|
|
<div class="example-contents">
|
|
<div class="phpcode"><pre><span style="color: #000000">
|
|
<span style="color: #0000BB"><?php<br />$dbconn </span><span style="color: #007700">= </span><span style="color: #0000BB">pg_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"dbname=publisher"</span><span style="color: #007700">) or die(</span><span style="color: #DD0000">"Could not connect"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$res </span><span style="color: #007700">= </span><span style="color: #0000BB">pg_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbconn</span><span style="color: #007700">, </span><span style="color: #DD0000">"SELECT bar FROM foo"</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #0000BB">pg_field_table</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">pg_field_table</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">, </span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$res </span><span style="color: #007700">= </span><span style="color: #0000BB">pg_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbconn</span><span style="color: #007700">, </span><span style="color: #DD0000">"SELECT version()"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">pg_field_table</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 /></span><span style="color: #0000BB">?></span>
|
|
</span>
|
|
</pre></div>
|
|
</div>
|
|
|
|
<div class="example-contents"><p>以上例程的输出类似于:</p></div>
|
|
<div class="example-contents screen">
|
|
<div class="cdata"><pre>
|
|
foo
|
|
14379580
|
|
|
|
bool(false)
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 notes" id="refsect1-function.pg-field-table-notes">
|
|
<h3 class="title">注释</h3>
|
|
<blockquote class="note"><p><strong class="note">Note</strong>:
|
|
<p class="para">
|
|
Returning the oid is much faster than returning the table name because
|
|
fetching the table name requires a query to the database system table.
|
|
</p>
|
|
</p></blockquote>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 seealso" id="refsect1-function.pg-field-table-seealso">
|
|
<h3 class="title">参见</h3>
|
|
<p class="para">
|
|
<ul class="simplelist">
|
|
<li class="member"><span class="function"><a href="pg_field_name.html" class="function" rel="rdfs-seeAlso">pg_field_name()</a> - 返回字段的名字</span></li>
|
|
<li class="member"><span class="function"><a href="pg_field_type.html" class="function" rel="rdfs-seeAlso">pg_field_type()</a> - 返回相应字段的类型名称</span></li>
|
|
</ul>
|
|
</p>
|
|
</div>
|
|
|
|
</div></div></div></body></html> |