From the course: PHP: Accessing Databases with PDO and MySQLi
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Freeing resources that are no longer needed - PHP Tutorial
From the course: PHP: Accessing Databases with PDO and MySQLi
Freeing resources that are no longer needed
Most of the time, PHP automatically frees up memory when resources are no longer needed. So it's common practice to leave the job of freeing resources to PHP's garbage collection. But with MySQLi there are times when you need to free resources explicitly, and in fact it's recommended you always do so. There are three methods that free up database resources in MySQLi, close, free and free_result. Let's take a look how they're used. With the MySQLi result object, all three have the same meaning. They free the memory associated with the result set and destroy the result object. With a prepared statement calling the close method, destroys the statement object, and cancels any results that haven't yet been retrieved from the database. Because prepared statements aren't buffered by default, you need to call the Close method before attempting to submit another query if the result set hasn't been completely consumed. Alternatively, use the store _result method to buffer the result set…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.