sqlsrv_errors
(Информация о версии неизвестна, возможно, только в SVN)
sqlsrv_errors — Returns error and warning information about the last SQLSRV operation performed
Описание
Returns error and warning information about the last SQLSRV operation performed.
Список параметров
-
errorsOrWarnings
-
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.
Возвращаемые значения
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:
Key | Description |
---|---|
SQLSTATE | 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. |
code | 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. |
message | A description of the error. |
Примеры
Пример #1 functionname() example
<?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 />";
}
}
}
?>
Примечания
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 sqlsrv_configure()
and the WarningsReturnAsErrors setting.
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Расширения для работы с базами данных
- Расширения для работы с базами данных отдельных производителей
- Microsoft SQL Server Driver for PHP
- sqlsrv_begin_transaction
- sqlsrv_cancel
- sqlsrv_client_info
- sqlsrv_close
- sqlsrv_commit
- sqlsrv_configure
- sqlsrv_connect
- sqlsrv_errors
- sqlsrv_execute
- sqlsrv_fetch_array
- sqlsrv_fetch_object
- sqlsrv_fetch
- sqlsrv_field_metadata
- sqlsrv_free_stmt
- sqlsrv_get_config
- sqlsrv_get_field
- sqlsrv_has_rows
- sqlsrv_next_result
- sqlsrv_num_fields
- sqlsrv_num_rows
- sqlsrv_prepare
- sqlsrv_query
- sqlsrv_rollback
- sqlsrv_rows_affected
- sqlsrv_send_stream_data
- sqlsrv_server_info
Коментарии
404 Not Found