parent functions and derived classes - the data problem
| From: | Tyson Lloyd Thwaites | Date: | Tue, 27 Feb 2001 00:40:21 +0000 |
| Subject: | parent functions and derived classes - the data problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-41772@lists.php.net to get a copy of this message | ||
Hi all,
I understand that you can call the parent function
from within an overriding child function using the
parent::method syntax. That's OK.
My problem is...I need the parent's data! (I know
that the class has no data, only objects of that
class have data, etc etc.)
I have a class that can execute SQL statements. It
is extended into many different classes that add
extra functionality - no rocket science.
What I want to do is add permission checking in
the child classes that then call the same function
in the parent *object. ie:
Class A {
function save() {
//refer to member data...
//execute sql based on member data...
}
}
Class B extends A {
function save() {
//check current user rights
//if ok, execute parent::save()
//BUT parent::save() won't have
//access to the member data it
//needs because it is a static call.
}
}
Any ideas? I have a feeling it could be achieved with
the serialize funtion, as I saw in the annotated manual,
but I don't quite understand what is going on in the
example. (I assume it is hacking the object's internal
representation so that it refers to a different class.
Scary.)
Thanks for any help
Regards,
Tyson Lloyd Thwaites
IT&e Limited
e-Commerce Division
Adelaide
(08) 8346 3888