php-doc-en/reference/sqlsrv/functions/sqlsrv-errors.xml
Philip Olson 04b11e621f Fixed spelling
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@329325 c90b9560-bf6c-de11-be94-00142212c4b1
2013-01-29 01:47:09 +00:00

159 lines
4.9 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.sqlsrv-errors" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>sqlsrv_errors</refname>
<refpurpose>Returns error and warning information about the last SQLSRV operation performed</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<!-- Example: All functions have this -->
<type>mixed</type><methodname>sqlsrv_errors</methodname>
<methodparam choice="opt"><type>int</type><parameter>errorsOrWarnings</parameter></methodparam>
</methodsynopsis>
<para>
Returns error and warning information about the last SQLSRV operation performed.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>errorsOrWarnings</parameter></term>
<listitem>
<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.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<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, &null; is returned. The following table
describes the structure of the returned arrays:
<table>
<title>Array returned by sqlsrv_errors</title>
<tgroup cols="2">
<thead>
<row>
<entry>Key</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>SQLSTATE</entry>
<entry>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.
</entry>
</row>
<row>
<entry>code</entry>
<entry>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.
</entry>
</row>
<row>
<entry>message</entry>
<entry>A description of the error.</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>functionname</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$serverName = "serverName/sqlexpress";
$connectionInfo = array( "Database"=>"dbName", "UID"=>"username", "PWD"=>"password");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn === false ) {
die( print_r( sqlsrv_errors(), true));
}
/* Set up a query to select an invalid column name. */
$sql = "SELECT BadColumnName FROM Table_1";
/* Execution of the query will fail because of the bad column name. */
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt === false ) {
if( ($errors = sqlsrv_errors() ) != null) {
foreach( $errors as $error ) {
echo "SQLSTATE: ".$error[ 'SQLSTATE']."<br />";
echo "code: ".$error[ 'code']."<br />";
echo "message: ".$error[ 'message']."<br />";
}
}
}
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
<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 &false;. However, warnings that correspond to SQLSTATE
values 01000, 01001, 01003, and 01S02 are never treated as errors. For
information about changing this behavior, see <function>sqlsrv_configure</function>
and the WarningsReturnAsErrors setting.
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>sqlsrv_configure</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->