Microsoft Drivers for PHP for SQL Server version 2.0 and 3.0 |
sqlsrv_has_rows |
Example See Also Send Feedback |
Indicates if the result set has one or more rows.
Syntax
sqlsrv_has_rows( resource $stmt ) |
Parameters
$stmt: The executed statement.
Return Value
If there are rows in the result set, the return value will be true. If there are no rows, or if the function call fails, the return value will be false.
Example
Copy Code | |
---|---|
<?php $server = "server_name"; $conn = sqlsrv_connect( $server, array( 'Database' => 'Northwind' ) ); $stmt = sqlsrv_query( $conn, "select * from orders where CustomerID = 'VINET'" , array()); if ($stmt !== NULL) { $rows = sqlsrv_has_rows( $stmt ); if ($rows === true) echo "\nthere are rows\n"; else echo "\nno rows\n"; } ?> |