Should the request be cleared if it's in the cycle?



  • There's a PHP crypt that uses mysqli♪ No requests for OBD are met in the cycle.

    <?php
    $mysqli = mysqli_connect('host','username','pass','dbname');
    

    for($i=0; $i<10; $i++) {
    $data = mysqli_query($mysqli, 'SELECT COUNT(*) FROM Booking WHERE route_id ='.$i);
    echo mysqli_fetch_row($data)[0];
    }

    Question: Should we call mysqli_free_result($data) in each cycle or memory is purified after each iteration?



  • No, you don't.
    Since you're rewriting the variable, you're rewriting all the data



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2