sqlsrv_num_fields
(No version information available, might only be in Git)
sqlsrv_num_fields — Retrieves the number of fields (columns) on a statement
Description
Retrieves the number of fields (columns) on a statement.
Parameters
-
stmt
-
The statment for which the number of fields is returned. sqlsrv_num_fields() can be called on a statement before or after statement execution.
Return Values
Returns the number of fields on success. Returns FALSE
otherwise.
Examples
Example #1 sqlsrv_num_fields() 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));
}
$sql = "SELECT * FROM Table_1";
$stmt = sqlsrv_query($conn, $sql);
if( $stmt === false) {
die( print_r( sqlsrv_errors(), true));
}
$numFields = sqlsrv_num_fields( $stmt );
while( sqlsrv_fetch( $stmt )) {
// Iterate through the fields of each row.
for($i = 0; $i < $numFields; $i++) {
{
echo sqlsrv_get_field($stmt, $i)." ";
}
echo "<br />";
}
?>
See Also
- sqlsrv_field_metadata() - Retrieves metadata for the fields of a statement prepared by sqlsrv_prepare or sqlsrv_query
- sqlsrv_fetch() - Makes the next row in a result set available for reading
- sqlsrv_get_field() - Gets field data from the currently selected row
- 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