略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: sqlsrv_num_fields

2024-11-14

sqlsrv_num_fields

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

sqlsrv_num_fieldsRetrieves the number of fields (columns) on a statement

说明

sqlsrv_num_fields(resource $stmt): mixed

Retrieves the number of fields (columns) on a statement.

参数

stmt

The statement for which the number of fields is returned. sqlsrv_num_fields() can be called on a statement before or after statement execution.

返回值

Returns the number of fields on success. Returns false otherwise.

范例

示例 #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_rsqlsrv_errors(), true));
}

$sql "SELECT * FROM Table_1";
$stmt sqlsrv_query($conn$sql);
if( 
$stmt === false) {
   die( 
print_rsqlsrv_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 />";
}
?>

参见

add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/function.sqlsrv-num-fields.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3