Page 1 of 1

scoping problem

Posted: Fri May 09, 2008 6:47 pm
by wmelnick
I have a generic mysql handling class which (among other functions) implements

insert
insertAndRetrieve

I also have a class that extends the above class and has a custom version of insert which encrypts credit card numbers.

The problem is that when insertAndRetrieve is called, it starts with a call to $this->insert which calls the generic one instead of the specific one because $this scopes to the generic (parent) class because insertAndretrieve is not overridden in the subclass. What can I put in place of $this that will make the call to the subclass?

Thanks,
Warren

Re: scoping problem

Posted: Fri May 09, 2008 11:15 pm
by flying_circus
Warren,

have a look at the PHP documentation for class scope.

http://www.php.net/manual/en/language.o ... otayim.php

You should be able to use the "self::" keyword to access the methods of the subclass or "parent::" keyword to access the methods of the parent class.

Re: scoping problem

Posted: Sat May 10, 2008 1:19 am
by RobertGonzalez
Can you show the parent class code (relevant bits) and the child classes (again relevant bits) and how you are calling the parent method from the child?