71008

Do I've to free mysql result after storing it?

I was wondering whether or not I've to call the $stmt->free_result() for after I've stored it's result with $stmt->store_result()? Could I rather just call $stmt->close() on the end?

The reason why I'm asking it is because when I call the $stmt->num_rows I've to call the $stmt->store_result() as said here: http://www.php.net/manual/en/mysqli-stmt.num-rows.php, but they don't call the $stmt->free_result() in their example. However, on the $stmt->store_result() they do: http://www.php.net/manual/en/mysqli-stmt.store-result.php.

Answer1:

You do not have to expressly free the result, but you can if you'd wish. If you don't, the result will be freed when the statement handle goes out of scope.

Answer2:

PHP is pretty lenient with freeing resources. Any resources used by your script, such as SQL connections, will be freed when the script exits. Although it's good programming practice, unless you have many concurrent users there will be very little difference in performance.

Recommend

  • Problems with inserting registering information into a Mysql database
  • Are mysqli_result::free and mysqli_stmt::free_result the same?
  • How to check a string does not start with a number in Batch?
  • Can't connect with PDO using ssl but mysqli with ssl works
  • Exporting SAS DataSet on to UNIX as a text file…with delimiter '~|~'
  • Fraction length
  • Getting syntax error in mysql-php. You have an error in your SQL syntax;
  • Compress a file with GZipStream while maintaining its meta-data
  • How do I retrieve the user information of a user authenticated with Apache's mod_ldap?
  • How can I include If-None-Match header in HttpRequestMessage
  • Suppressing passwd when calling sqlplus from shell script
  • Security issues with PHP's Readfile method
  • Parse a date string in a specific locale (not timezone!)
  • Syntax for setting draggablecursor property in google maps api
  • Seeking advice on Jetty HttpClient Hang
  • MongoDB in PHP using aggregate to group by _id is null not working
  • does jqgrid support a multiple checkbox list for editing
  • How do I change content of ComboFieldEditor?
  • FB SDK and cURL: Unknown SSL protocol error in connection to graph.facebook.com:443
  • Retrieving value from sql ExecuteScalar()
  • Display issues when we change from one jquery mobile page to another in firefox
  • Why ng-show works with ng-repeat but ng-if doesn't? [duplicate]
  • Optimizing database types to compact database (SQLite)
  • Get object from AWS S3 as a stream
  • Cross-Platform Protobuf Serialization
  • Validaiting emails with Net.Mail MailAddress
  • MySQL WHERE-condition in procedure ignored
  • vba code to select only visible cells in specific column except heading
  • Upload files with Ajax and Jquery
  • Weird JavaScript statement, what does it mean?
  • Delete MySQLi record without showing the id in the URL
  • bootstrap to use multiple ng-app
  • Transpose CSV data with awk (pivot transformation)
  • How to get icons for entities from eclipse?
  • A cron job substitute?
  • json Serialization in asp
  • SQL merge duplicate rows and join values that are different
  • Turn off referential integrity in Derby? is it possible?
  • JaxB to read class hierarchy
  • Sorting a 2D array using the second column C++