Re: parent functions and derived classes - the data problem

From: Date: Mon, 26 Feb 2001 21:33:52 +0000
Subject: Re: parent functions and derived classes - the data problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-41775@lists.php.net to get a copy of this message
Actually, static calls aren't so static when they're calling a method which is in the inheritance tree. In other words, parent:: calls (assuming the subclass is instanciated) will operate instanciated. John On Tue, 27 Feb 2001, Tyson Lloyd Thwaites wrote: > 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 > > -- John Donagher Application Engineer Intacct Corp. - Powerful Accounting on the Web 408-395-0989 720 University Ave. Los Gatos CA 95032 www.intacct.com Public key available off http://www.keyserver.net Key fingerprint = 4024 DF50 56EE 19A3 258A D628 22DE AD56 EEBE 8DDD

« previous php.general (#41775) next »