First line access of a query without sqlsrv_fecth_array

Asked

Viewed 31 times

0

I have a query and would like to access the first line without using sqlsrv_fetch_array, because this function already jumps to the next line and I would not like it to occur.

 $resultado = sqlsrv_query($conexao98, $query, $params, $options) or die(print_r(sqlsrv_errors())); 

I want to recover the first field of the first line of "$result" without this line being lost.

  • Every time you extract a line from the result set it is removed. I think there is another way to solve this, I just don’t quite understand what the problem is.

  • good, it’s just that I need to catch a field before I enter my loop to display the lines, only if I use it the first line gets lost

  • would like to know how to extract without removing

  • your result comes as? has how you insert an example?

  • @Diegobraga just want to access the $result without removing the accessed line

  • If the result set is not extracted your while goes into infinite loop. I imagine something like $valido = false; $primeiraLinha = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC); if($primeiraLinha ...){ $valido = true} while($row = sqlsrv.....){ if($valido) { executado algo } else{ executa outra coisa} }

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.