title: PHP DELETE immediately after select
body: <p>I have a PHP server script that SELECTs some data from a MySQL database.</p>
  
  <p>As soon as I have the result from mysql_query and mysql_fetch_assoc stored in my own local variables, I want to delete the row I just selected.</p>
  
  <p>The problem with this approach is that it seems that PHP has done pass-by-reference to my local variables instead of pass-by-value, and my local variables become undefined after the delete command.</p>
  
  <p>Is there anyway to get around this? Here is my code:</p>
  
  <pre><code>    $query="SELECT id, peerID, name FROM names WHERE peer = $userID AND docID = '$docID' AND seqNo = $nid";
      $result = mysql_query($query);
  
      if (!$result)
          self::logError("FAIL:1 getUsersNamesUpdate() query: ".$query."\n");     
  
      if (mysql_num_rows($result) == 0)
          return array();
  
      $row = mysql_fetch_assoc($result);
      $result = array();
      $result["id"] = $row["id"];
      $result["peerID"] = $row["peerID"];
      $result["name"] = $row["name"];
  
      $query="DELETE FROM names WHERE id = $result[id];";
      $result = mysql_query($query);
  
      if (!$result)
          self::logError("FAIL:2 getUsersNamesUpdate() query: ".$query."\n");         
  
      return $result;
  </code></pre>