title: SQL server transactions in PHP
body: <p>I'm trying to grasp the idea of transactions fully. Therefore the following question... (ofcourse newbie, so don't laugh :D )</p>
  
  <p>I have set up a (simplified) transaction in PHP (using the PHP SQL driver from microsoft). I want to get the rows I'm going to delete for some extra processing later:</p>
  
  <pre><code>sqlsrv_begin_transaction($conn);
  $sql = "SELECT * FROM test WITH (XLOCK) WHERE a&lt;10";
  $statement = sqlsrv_query($conn,$sql);
  $sql = "DELETE FROM test WHERE a&lt;10";
  sqlsrv_query($conn,$sql);
  
  $result = get_result_array($statement);
  sqlsrv_commit($conn);
  $result2 = get_result_array($statement);
  </code></pre>
  
  <p>1) I do get the expected result in $result but an empty array in $result2. Why?</p>
  
  <p>I would expect only a result in $result2 because then the transaction has actually been executed. I guess the result in $result is a sort of 'temporary' result in memory and not actually a result from the actual database.</p>
  
  <p>2) It could be that between the moment the transaction was started and the actual commit, an other query from another connection has changed the rows which match (a&lt;10)? That means that the results I'm expecting according to $result will be different from the actual changes in the database.</p>
  
  <p>Or is it that (a) the transaction occurres with an in-memory copy of the database (not affected by in-between queries from other connections), or (b) the locks obtained since the beginning of the transaction are already in action for other queries from other connections?</p>
  
  <p>After typing this I'm expecting answer b....?</p>