⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 function.pg-result-error-field.html

📁 php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>Returns an individual field of an error report.</title>  <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.pg-query.html">pg_query</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.pg-result-error.html">pg_result_error</a></div> <div class="up"><a href="ref.pgsql.html">PostgreSQL Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.pg-result-error-field" class="refentry"> <div class="refnamediv">  <h1 class="refname">pg_result_error_field</h1>  <p class="verinfo">(PHP 5 &gt;= 5.1.0)</p><p class="refpurpose"><span class="refname">pg_result_error_field</span> &mdash; <span class="dc-title">Returns an individual field of an error report.</span></p> </div> <div class="refsect1 description">  <h3 class="title">Description</h3>  <div class="methodsynopsis dc-description">   <span class="type">string</span> <span class="methodname"><b><b>pg_result_error_field</b></b></span>    ( <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$result</tt></span>   , <span class="methodparam"><span class="type">int</span> <tt class="parameter">$fieldcode</tt></span>   )</div>  <p class="para rdfs-comment">   <b>pg_result_error_field()</b> returns one of the detailed error message   fields associated with <i><tt class="parameter">result</tt></i> resource. It is only available   against a PostgreSQL 7.4 or above server.  The error field is specified by   the <i><tt class="parameter">fieldcode</tt></i>.  </p>  <p class="para">   Because <a href="function.pg-query.html" class="function">pg_query()</a> and <a href="function.pg-query-params.html" class="function">pg_query_params()</a> return <b><tt>FALSE</tt></b> if the query fails,   you must use <a href="function.pg-send-query.html" class="function">pg_send_query()</a> and   <a href="function.pg-get-result.html" class="function">pg_get_result()</a> to get the result handle.  </p>  <p class="para">   If you need to get additional error information from failed <a href="function.pg-query.html" class="function">pg_query()</a> queries,     use <a href="function.pg-set-error-verbosity.html" class="function">pg_set_error_verbosity()</a> and <a href="function.pg-last-error.html" class="function">pg_last_error()</a>   and then parse the result.  </p> </div> <div class="refsect1 parameters">  <h3 class="title">Parameters</h3>  <p class="para">   <dl>    <dt>     <span class="term"><i><tt class="parameter">result</tt></i></span>     <dd>      <p class="para">       A PostgreSQL query result resource from a previously executed       statement.      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">fieldcode</tt></i></span>     <dd>        <p class="para">         Possible <i><tt class="parameter">fieldcode</tt></i> values are: <b><tt>PGSQL_DIAG_SEVERITY</tt></b>,         <b><tt>PGSQL_DIAG_SQLSTATE</tt></b>, <b><tt>PGSQL_DIAG_MESSAGE_PRIMARY</tt></b>,         <b><tt>PGSQL_DIAG_MESSAGE_DETAIL</tt></b>,         <b><tt>PGSQL_DIAG_MESSAGE_HINT</tt></b>, <b><tt>PGSQL_DIAG_STATEMENT_POSITION</tt></b>,         <b><tt>PGSQL_DIAG_INTERNAL_POSITION</tt></b> (PostgreSQL 8.0+ only),         <b><tt>PGSQL_DIAG_INTERNAL_QUERY</tt></b> (PostgreSQL 8.0+ only),         <b><tt>PGSQL_DIAG_CONTEXT</tt></b>, <b><tt>PGSQL_DIAG_SOURCE_FILE</tt></b>,         <b><tt>PGSQL_DIAG_SOURCE_LINE</tt></b> or         <b><tt>PGSQL_DIAG_SOURCE_FUNCTION</tt></b>.        </p>     </dd>    </dt>   </dl>  </p> </div> <div class="refsect1 returnvalues">  <h3 class="title">Return Values</h3>  <p class="para">A <a href="language.types.string.html" class="type string">string</a> containing the contents of the error field, <b><tt>NULL</tt></b> if the field does not exist or <b><tt>FALSE</tt></b>  on failure.</p> </div>  <div class="refsect1 examples">  <h3 class="title">Examples</h3>  <p class="para">   <div class="example">    <p><b>Example #1 <b>pg_result_error_field()</b> example</b></p>    <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;$dbconn&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"dbname=publisher"</span><span style="color: #007700">)&nbsp;or&nbsp;die(</span><span style="color: #DD0000">"Could&nbsp;not&nbsp;connect"</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;if&nbsp;(!</span><span style="color: #0000BB">pg_connection_busy</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbconn</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">pg_send_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbconn</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"select&nbsp;*&nbsp;from&nbsp;doesnotexist;"</span><span style="color: #007700">);<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$res1&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_get_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbconn</span><span style="color: #007700">);<br />&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">pg_result_error_field</span><span style="color: #007700">(</span><span style="color: #0000BB">$res1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">PGSQL_DIAG_SQLSTATE</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>    </div>   </div>  </p> </div> <div class="refsect1 seealso">  <h3 class="title">See Also</h3>  <p class="para">   <ul class="simplelist">    <li class="member"><a href="function.pg-result-error.html" class="function" rel="rdfs-seeAlso">pg_result_error()</a></li>   </ul>  </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.pg-query.html">pg_query</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.pg-result-error.html">pg_result_error</a></div> <div class="up"><a href="ref.pgsql.html">PostgreSQL Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -