Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8819219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:18:01+00:00 2026-06-14T05:18:01+00:00

When using mysql_query inside of a class method and setting it to a local

  • 0

When using mysql_query inside of a class method and setting it to a local variable is memory freed when the method finishes execution or at the end of the script? Is it worth adding mysql_free_result? Below is example.

class example{
    public function Query($query){
        $result = mysql_query($query);
        while ($row = mysql_fetch_assoc($result))
        {
            $this->rows[] =$row;
        }
    }
}

Will memory be freed when the method finishes or is it necessary to call mysql_free_result at the end of the method?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:18:03+00:00Added an answer on June 14, 2026 at 5:18 am

    First of all, mysql_ php functions are not maintained anymore and thus you may want to use a more OOP approach such as mysqli or PDO functions.

    Since mysql_free_result()

    will free all memory associated with the result identifier result.

    If you are fetching a lot of results then yes, you can (and should) use this function to free your mysql to save memory.

    As for the rest of your question:

    Will memory be freed when the method finishes or is it necessary to call mysql_free_result at the end of the method?

    No, in case of you are not using the mysql_free_result the memory won’t be freed at the end of your method but rather in the end of the execution of your script.

    I hope it helped. Cheers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using mysql_query(INSERT INTO imaegs_backup SELECT * FROM images); in order to copy
Suppose I am executing several queries on the server using mysql_query . The results
I am using a PHP mySQL query. Struggling with a Joins. mysql_query(SELECT * FROM
I am wondering how $link can be undefined. It is a global inside class
I am using phpmailer, and have customised it for my needs. Inside $templatemessage is
I want to execute a query inside a db.sql file using MySQL 5.1 in
I am using MySQL database and I have a datetime field inside it. In
Here's the one I'm using: <?php final class Database { private static $oDb; public
MySQL Query works fine using MySQL workbench but produces an error when I am
I have tried fetching MySQL query results using mysql_fetch_row() and mysql_result() and numeric values

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.