1

I have a function in a child class which counts the number of SQL queries in a page load

In the child class which extends the parent class, after every: mysql_query($query);

I put parent::update_query_function();

where update_query_function() is:

function update_query_function(){

$this->query_num++;

}

the $query_num variable in the parent class is not being updated. Why?

2
  • Just a quick thought - I might be wrong - but if you have multiple instantiations of the child class, won't they each have a separate instantiation of the parent class and therefore a separate query count. Does that affect what you're trying to achieve? Commented Sep 24, 2010 at 11:50
  • It would do - yes. I need one concrete number for the total query count. Commented Sep 24, 2010 at 12:32

1 Answer 1

1

If your child class extends the parent class there's no need to do that, do this instead:

$this->update_query_function();

that's the point of inheritance.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.