Try to avoid using this function if you need good performance. Specifying "Scrollable" in the options will make you queries take ages to run. If your result contains less than 5000 rows (might vary on different hardware) its faster to not use "Scrollable" and loop over them in php instead.
If you need to check if a result contains rows use "sqlsrv_has_rows()", this function works without "Scrollable". After removing all my "Scrollable" queries, my page loadtime went from 900ms to 60ms.
To demonstrate, here is a query that returns 100 rows:
<?php
for($i = 0; $i < 100; $i++) {
$q = "SELECT sku,name FROM product WHERE visible = 1";
$result = sqlsrv_query($db,$q,array(), array( "Scrollable" => SQLSRV_CURSOR_KEYSET ));
while($row = sqlsrv_fetch_array($result)) {}
}
?>
This takes about 10s! Thats 10 qps..
Now if we remove "Scrollable":
<?php
for($i = 0; $i < 100; $i++) {
$q = "SELECT sku,name FROM product WHERE visible = 1";
$result = sqlsrv_query($db,$q);
while($row = sqlsrv_fetch_array($result)) {}
}
?>
This will run in 300ms, about 334 qps!