title: When to close Prepared Statement
body: <p>When to close prepared statements in PHP?</p>
  
  <p>Example:</p>
  
  <pre><code>    $query = "insert into web_reviews (title,added_date,reviewer_home_url,read_more_link,summary) values(?,?,?,?,?)";
      $stmt = $this-&gt;db-&gt;prepare($query);
      $stmt-&gt;bind_params($this-&gt;title,$this-&gt;added_date,$this-&gt;reviewer_home_url,$this-&gt;read_more,$this-&gt;summary);
      $stmt-&gt;execute() or die("Cannot add the date to the database, please try again.");
      $stmt-&gt;close();
  
      $stmt = $this-&gt;db-&gt;prepare("select id from web_reviews where title = ? and read_more = ?");
      $stmt-&gt;bind_params($this-&gt;title,$this-&gt;read_more);
      $stmt-&gt;execute();
      $stmt-&gt;bind_results($web_review_id);
      $stmt-&gt;close();
  </code></pre>
  
  <p>Should I use <code>$stmt-&gt;close();</code> here? </p>
  
  <p><strong>Edit:</strong></p>
  
  <p>What is written on the PHP Manual and also one comment from the manual says:</p>
  
  <blockquote>
    <p>Closes a prepared statement.
    mysqli_stmt_close() also deallocates
    the statement handle. If the current
    statement has pending or unread
    results, this function cancels them so
    that the next query can be executed.</p>
  </blockquote>
  
  <p>Comment:</p>
  
  <blockquote>
    <p>if you are repeating an statement in
    an loop using bind_param and so on
    inside it for a larger operation. i
    thougt id would be good to clean it
    with stmt->close. but it broke always
    with an error after aprox. 250
    operations . As i tried it with 
    stmt->reset it worked for me.</p>
  </blockquote>