Query: sqlsrv_num_rows
OS: php
Section: 3
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
SQLSRV_NUM_ROWS(3) SQLSRV_NUM_ROWS(3) sqlsrv_num_rows - Retrieves the number of rows in a result setSYNOPSISmixed sqlsrv_num_rows (resource $stmt)DESCRIPTIONRetrieves the number of rows in a result set. This function requires that the statment resource be created with a static or keyset cursor. For more information, see sqlsrv_query(3), sqlsrv_prepare(3), or Specifying a Cursor Type and Selecting Rows in the Microsoft SQLSRV docu- mentation.PARAMETERSo $stmt - The statement for which the row count is returned. The statment resource must be created with a static or keyset cursor. For more information, see sqlsrv_query(3), sqlsrv_prepare(3), or Specifying a Cursor Type and Selecting Rows in the Microsoft SQLSRV documentation.RETURN VALUESReturns the number of rows retrieved on success and FALSE if an error occurred. If a forward cursor (the default) or dynamic cursor is used, FALSE is returned.EXAMPLESExample #1 sqlsrv_num_rows(3) example <?php $server = "serverNamesqlexpress"; $connectionInfo = array( "Database"=>"dbName", "UID"=>"username", "PWD"=>"password" ); $conn = sqlsrv_connect( $server, $connectionInfo ); $sql = "SELECT * FROM Table_1"; $params = array(); $options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET ); $stmt = sqlsrv_query( $conn, $sql , $params, $options ); $row_count = sqlsrv_num_rows( $stmt ); if ($row_count === false) echo "Error in retrieveing row count."; else echo $row_count; ?>SEE ALSOsqlsrv_has_rows(3), sqlsrv_rows_affected(3). PHP Documentation Group SQLSRV_NUM_ROWS(3)