function.oci-error.html
来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 162 行
HTML
162 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Returns the last error found</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.oci-define-by-name.html">oci_define_by_name</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.oci-execute.html">oci_execute</a></div> <div class="up"><a href="ref.oci8.html">OCI8 Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.oci-error" class="refentry"> <div class="refnamediv"> <h1 class="refname">oci_error</h1> <p class="verinfo">(PHP 5, PECL oci8:1.1-1.2.4)</p><p class="refpurpose"><span class="refname">oci_error</span> — <span class="dc-title">Returns the last error found</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">array</span> <span class="methodname"><b><b>oci_error</b></b></span> ([ <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$source</tt></span> ] )</div> <p class="para rdfs-comment"> Returns the last error found. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">source</tt></i></span> <dd> <p class="para"> For most errors, the parameter is the most appropriate resource handle. For connection errors with <a href="function.oci-connect.html" class="function">oci_connect()</a>, <a href="function.oci-new-connect.html" class="function">oci_new_connect()</a> or <a href="function.oci-pconnect.html" class="function">oci_pconnect()</a> do not pass a parameter. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> If no error is found, <b>oci_error()</b> returns <b><tt>FALSE</tt></b>. <b>oci_error()</b> returns the error as an associative array. In this array, <i>code</i> consists the oracle error code and <i>message</i> the oracle error string. </p> </div> <div class="refsect1 changelog"> <h3 class="title">ChangeLog</h3> <p class="para"> <table class="informaltable"> <colgroup> <thead valign="middle"> <tr valign="middle"> <th colspan="1">Version</th> <th colspan="1">Description</th> </tr> </thead> <tbody valign="middle" class="tbody"> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">4.3</td> <td colspan="1" rowspan="1" align="left"> <i>offset</i> and <i>sqltext</i> will also be included in the return array to indicate the location of the error and the original SQL text which caused it. </td> </tr> </tbody> </colgroup> </table> </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 Displaying the Oracle error message after a connection error</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000">$conn = @oci_connect("scott", "tiger", "mydb");<br />if (!$conn) {<br /> $e = oci_error(); // For oci_connect errors pass no handle<br /> echo htmlentities($e['message']);<br />}</span></code></div> </div> </div> </p> <p class="para"> <div class="example"> <p><b>Example #2 Displaying the Oracle error message after a parsing error</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000">$stmt = @oci_parse($conn, "select ' from dual"); // note mismatched quote<br />if (!$stmt) {<br /> $e = oci_error($conn); // For oci_parse errors pass the connection handle<br /> echo htmlentities($e['message']);<br />}</span></code></div> </div> </div> </p> <p class="para"> <div class="example"> <p><b>Example #3 Displaying the Oracle error message and problematic statement after an execution error</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000">$r = oci_execute($stmt);<br />if (!$r) {<br /> $e = oci_error($stmt); // For oci_execute errors pass the statementhandle<br /> echo htmlentities($e['message']);<br /> echo "<pre>";<br /> echo htmlentities($e['sqltext']);<br /> printf("\n%".($e['offset']+1)."s", "^");<br /> echo "</pre>";<br />}</span></code></div> </div> </div> </p> </div> <div class="refsect1 notes"> <h3 class="title">Notes</h3> <blockquote><p><b class="note">Note</b>: In PHP versions before 5.0.0 you must use <a href="function.ocierror.html" class="function">ocierror()</a> instead. This name still can be used, it was left as alias of <b>oci_error()</b> for downwards compatability. This, however, is deprecated and not recommended. <br /> </p></blockquote> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.oci-define-by-name.html">oci_define_by_name</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.oci-execute.html">oci_execute</a></div> <div class="up"><a href="ref.oci8.html">OCI8 Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?