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
scoping problem
Moderator: General Moderators
- flying_circus
- Forum Regular
- Posts: 732
- Joined: Wed Mar 05, 2008 10:23 pm
- Location: Sunriver, OR
Re: scoping problem
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.
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.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: scoping problem
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?