mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 22:06:57 +08:00
143 lines
9.9 KiB
HTML
143 lines
9.9 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 error and warning information about the last SQLSRV operation performed</title>
|
|
</head>
|
|
<body class="docs"><div id="layout">
|
|
<div id="layout-content"><div id="function.sqlsrv-errors" class="refentry">
|
|
<div class="refnamediv">
|
|
<h1 class="refname">sqlsrv_errors</h1>
|
|
<p class="verinfo">(No version information available, might only be in Git)</p><p class="refpurpose"><span class="refname">sqlsrv_errors</span> — <span class="dc-title">Returns error and warning information about the last SQLSRV operation performed</span></p>
|
|
|
|
</div>
|
|
<div class="refsect1 description" id="refsect1-function.sqlsrv-errors-description">
|
|
<h3 class="title">说明</h3>
|
|
<div class="methodsynopsis dc-description">
|
|
|
|
<span class="methodname"><strong>sqlsrv_errors</strong></span>
|
|
([ <span class="methodparam"><span class="type">int</span> <code class="parameter">$errorsOrWarnings</code></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">
|
|
Returns error and warning information about the last SQLSRV operation performed.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 parameters" id="refsect1-function.sqlsrv-errors-parameters">
|
|
<h3 class="title">参数</h3>
|
|
<p class="para">
|
|
<dl>
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">errorsOrWarnings</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
Determines whether error information, warning information, or both are
|
|
returned. If this parameter is not supplied, both error information and
|
|
warning information are returned. The following are the supported values
|
|
for this parameter: SQLSRV_ERR_ALL, SQLSRV_ERR_ERRORS, SQLSRV_ERR_WARNINGS.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
</dl>
|
|
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 returnvalues" id="refsect1-function.sqlsrv-errors-returnvalues">
|
|
<h3 class="title">返回值</h3>
|
|
<p class="para">
|
|
If errors and/or warnings occurred on the last sqlsrv operation, an array of
|
|
arrays containing error information is returned. If no errors and/or warnings
|
|
occurred on the last sqlsrv operation, <strong><code>NULL</code></strong> is returned. The following table
|
|
describes the structure of the returned arrays:
|
|
<table class="doctable table">
|
|
<caption><strong>Array returned by sqlsrv_errors</strong></caption>
|
|
|
|
<thead>
|
|
<tr>
|
|
<th>Key</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody class="tbody">
|
|
<tr>
|
|
<td>SQLSTATE</td>
|
|
<td>For errors that originate from the ODBC driver, the SQLSTATE returned
|
|
by ODBC. For errors that originate from the Microsoft Drivers for PHP for
|
|
SQL Server, a SQLSTATE of IMSSP. For warnings that originate from the
|
|
Microsoft Drivers for PHP for SQL Server, a SQLSTATE of 01SSP.
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>code</td>
|
|
<td>For errors that originate from SQL Server, the native SQL Server
|
|
error code. For errors that originate from the ODBC driver, the error
|
|
code returned by ODBC. For errors that originate from the Microsoft Drivers
|
|
for PHP for SQL Server, the Microsoft Drivers for PHP for SQL Server error code.
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>message</td>
|
|
<td>A description of the error.</td>
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 examples" id="refsect1-function.sqlsrv-errors-examples">
|
|
<h3 class="title">范例</h3>
|
|
<p class="para">
|
|
<div class="example" id="example-2574">
|
|
<p><strong>Example #1 <span class="function"><strong>functionname()</strong></span> example</strong></p>
|
|
<div class="example-contents">
|
|
<div class="phpcode"><pre><span style="color: #000000">
|
|
<span style="color: #0000BB"><?php<br />$serverName </span><span style="color: #007700">= </span><span style="color: #DD0000">"serverName/sqlexpress"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$connectionInfo </span><span style="color: #007700">= array( </span><span style="color: #DD0000">"Database"</span><span style="color: #007700">=></span><span style="color: #DD0000">"dbName"</span><span style="color: #007700">, </span><span style="color: #DD0000">"UID"</span><span style="color: #007700">=></span><span style="color: #DD0000">"username"</span><span style="color: #007700">, </span><span style="color: #DD0000">"PWD"</span><span style="color: #007700">=></span><span style="color: #DD0000">"password"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$conn </span><span style="color: #007700">= </span><span style="color: #0000BB">sqlsrv_connect</span><span style="color: #007700">( </span><span style="color: #0000BB">$serverName</span><span style="color: #007700">, </span><span style="color: #0000BB">$connectionInfo</span><span style="color: #007700">);<br />if( </span><span style="color: #0000BB">$conn </span><span style="color: #007700">=== </span><span style="color: #0000BB">false </span><span style="color: #007700">) {<br /> die( </span><span style="color: #0000BB">print_r</span><span style="color: #007700">( </span><span style="color: #0000BB">sqlsrv_errors</span><span style="color: #007700">(), </span><span style="color: #0000BB">true</span><span style="color: #007700">));<br />}<br /><br /></span><span style="color: #FF8000">/* Set up a query to select an invalid column name. */<br /></span><span style="color: #0000BB">$sql </span><span style="color: #007700">= </span><span style="color: #DD0000">"SELECT BadColumnName FROM Table_1"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">/* Execution of the query will fail because of the bad column name. */<br /></span><span style="color: #0000BB">$stmt </span><span style="color: #007700">= </span><span style="color: #0000BB">sqlsrv_query</span><span style="color: #007700">( </span><span style="color: #0000BB">$conn</span><span style="color: #007700">, </span><span style="color: #0000BB">$sql </span><span style="color: #007700">);<br />if( </span><span style="color: #0000BB">$stmt </span><span style="color: #007700">=== </span><span style="color: #0000BB">false </span><span style="color: #007700">) {<br /> if( (</span><span style="color: #0000BB">$errors </span><span style="color: #007700">= </span><span style="color: #0000BB">sqlsrv_errors</span><span style="color: #007700">() ) != </span><span style="color: #0000BB">null</span><span style="color: #007700">) {<br /> foreach( </span><span style="color: #0000BB">$errors </span><span style="color: #007700">as </span><span style="color: #0000BB">$error </span><span style="color: #007700">) {<br /> echo </span><span style="color: #DD0000">"SQLSTATE: "</span><span style="color: #007700">.</span><span style="color: #0000BB">$error</span><span style="color: #007700">[ </span><span style="color: #DD0000">'SQLSTATE'</span><span style="color: #007700">].</span><span style="color: #DD0000">"<br />"</span><span style="color: #007700">;<br /> echo </span><span style="color: #DD0000">"code: "</span><span style="color: #007700">.</span><span style="color: #0000BB">$error</span><span style="color: #007700">[ </span><span style="color: #DD0000">'code'</span><span style="color: #007700">].</span><span style="color: #DD0000">"<br />"</span><span style="color: #007700">;<br /> echo </span><span style="color: #DD0000">"message: "</span><span style="color: #007700">.</span><span style="color: #0000BB">$error</span><span style="color: #007700">[ </span><span style="color: #DD0000">'message'</span><span style="color: #007700">].</span><span style="color: #DD0000">"<br />"</span><span style="color: #007700">;<br /> }<br /> }<br />}<br /></span><span style="color: #0000BB">?></span>
|
|
</span>
|
|
</pre></div>
|
|
</div>
|
|
|
|
</div>
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 notes" id="refsect1-function.sqlsrv-errors-notes">
|
|
<h3 class="title">注释</h3>
|
|
<p class="para">
|
|
By default, warnings generated on a call to any SQLSRV function are treated
|
|
as errors. This means that if a warning occurs on a call to a SQLSRV function,
|
|
the function returns <strong><code>FALSE</code></strong>. However, warnings that correspond to SQLSTATE
|
|
values 01000, 01001, 01003, and 01S02 are never treated as errors. For
|
|
information about changing this behavior, see <span class="function"><a href="sqlsrv_configure.html" class="function">sqlsrv_configure()</a></span>
|
|
and the WarningsReturnAsErrors setting.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 seealso" id="refsect1-function.sqlsrv-errors-seealso">
|
|
<h3 class="title">参见</h3>
|
|
<p class="para">
|
|
<ul class="simplelist">
|
|
<li class="member"><span class="function"><a href="sqlsrv_configure.html" class="function" rel="rdfs-seeAlso">sqlsrv_configure()</a> - Changes the driver error handling and logging configurations</span></li>
|
|
</ul>
|
|
</p>
|
|
</div>
|
|
|
|
</div></div></div></body></html> |