No cache version.

Caching disabled. Default setting for this page:enabled (code LNG204)
If the display is too slow, you can disable the user mode to view the cached version.

Rechercher une fonction PHP

sqlsrv_get_field

(No version information available, might only be in Git)

sqlsrv_get_fieldGets field data from the currently selected row

Description

sqlsrv_get_field ( resource $stmt , int $fieldIndex [, int $getAsType ] ) : mixed

Gets field data from the currently selected row. Fields must be accessed in order. Field indices start at 0.

PHP: sqlsrv_get_field - Manual Home of Manuel PHP  Contents Haut

Parameters

stmt

A statement resource returned by sqlsrv_query() or sqlsrv_execute().

fieldIndex

The index of the field to be retrieved. Field indices start at 0. Fields must be accessed in order. i.e. If you access field index 1, then field index 0 will not be available.

getAsType

The PHP data type for the returned field data. If this parameter is not set, the field data will be returned as its default PHP data type. For information about default PHP data types, see » Default PHP Data Types in the Microsoft SQLSRV documentation.

PHP: sqlsrv_get_field - Manual Home of Manuel PHP  Contents Haut

Return Values

Returns data from the specified field on success. Returns FALSE otherwise.

PHP: sqlsrv_get_field - Manual Home of Manuel PHP  Contents Haut

Examples

Example #1 sqlsrv_get_field() example

The following example demonstrates how to retrieve a row with sqlsrv_fetch() and get the row fields with sqlsrv_get_field().

<?php
$serverName 
"serverName\sqlexpress";
$connectionInfo = array( "Database"=>"dbName""UID"=>"username""PWD"=>"password");
$conn sqlsrv_connect$serverName$connectionInfo);
if( 
$conn === false ) {
     die( 
print_rsqlsrv_errors(), true));
}

$sql "SELECT Name, Comment 
        FROM Table_1
        WHERE ReviewID=1"
;
$stmt sqlsrv_query$conn$sql);
if( 
$stmt === false ) {
     die( 
print_rsqlsrv_errors(), true));
}

// Make the first (and in this case, only) row of the result set available for reading.
if( sqlsrv_fetch$stmt ) === false) {
     die( 
print_rsqlsrv_errors(), true));
}

// Get the row fields. Field indices start at 0 and must be retrieved in order.
// Retrieving row fields by name is not supported by sqlsrv_get_field.
$name sqlsrv_get_field$stmt0);
echo 
"$name: ";

$comment sqlsrv_get_field$stmt1);
echo 
$comment;
?>

PHP: sqlsrv_get_field - Manual Home of Manuel PHP  Contents Haut

See Also

Find a PHP function

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-function.sqlsrv-get-field.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.

References

  1. View the html document Language of the document:fr Manuel PHP : http://php.net

These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.

Contents Haut