📄 function.pg-result-error.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Get error message associated with result</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-result-error-field.html">pg_result_error_field</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.pg-result-seek.html">pg_result_seek</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" class="refentry"> <div class="refnamediv"> <h1 class="refname">pg_result_error</h1> <p class="verinfo">(PHP 4 >= 4.2.0, PHP 5)</p><p class="refpurpose"><span class="refname">pg_result_error</span> — <span class="dc-title"> Get error message associated with result </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</b></b></span> ( <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$result</tt></span> )</div> <p class="para rdfs-comment"> <b>pg_result_error()</b> returns any error message associated with the <i><tt class="parameter">result</tt></i> resource. Therefore, the user has a better chance of getting the correct error message than with <a href="function.pg-last-error.html" class="function">pg_last_error()</a>. </p> <p class="para"> The function <a href="function.pg-result-error-field.html" class="function">pg_result_error_field()</a> can give much greater detail on result errors than <b>pg_result_error()</b>. </p> <p class="para"> Because <a href="function.pg-query.html" class="function">pg_query()</a> returns <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> </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"> PostgreSQL query result resource, returned by <a href="function.pg-query.html" class="function">pg_query()</a>, <a href="function.pg-query-params.html" class="function">pg_query_params()</a> or <a href="function.pg-execute.html" class="function">pg_execute()</a> (among others). </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns a <a href="language.types.string.html" class="type string">string</a> if there is an error associated with the <i><tt class="parameter">result</tt></i> parameter, <b><tt>FALSE</tt></b> otherwise. </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()</b> example</b></p> <div class="example-contents"><div class="phpcode"><code><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 /> if (!</span><span style="color: #0000BB">pg_connection_busy</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbconn</span><span style="color: #007700">)) {<br /> </span><span style="color: #0000BB">pg_send_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbconn</span><span style="color: #007700">, </span><span style="color: #DD0000">"select * from doesnotexist;"</span><span style="color: #007700">);<br /> }<br /> <br /> </span><span style="color: #0000BB">$res1 </span><span style="color: #007700">= </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 /> echo </span><span style="color: #0000BB">pg_result_error</span><span style="color: #007700">(</span><span style="color: #0000BB">$res1</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></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-field.html" class="function" rel="rdfs-seeAlso">pg_result_error_field()</a></li> <li class="member"><a href="function.pg-query.html" class="function" rel="rdfs-seeAlso">pg_query()</a></li> <li class="member"><a href="function.pg-send-query.html" class="function" rel="rdfs-seeAlso">pg_send_query()</a></li> <li class="member"><a href="function.pg-get-result.html" class="function" rel="rdfs-seeAlso">pg_get_result()</a></li> <li class="member"><a href="function.pg-last-error.html" class="function" rel="rdfs-seeAlso">pg_last_error()</a></li> <li class="member"><a href="function.pg-last-notice.html" class="function" rel="rdfs-seeAlso">pg_last_notice()</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-result-error-field.html">pg_result_error_field</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.pg-result-seek.html">pg_result_seek</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 + -