sangoku Posted February 20, 2010 Share Posted February 20, 2010 Hy i have a bit of a dilemma here the one like what first egg or the chicken... Here is my dilemma i have classes like: attachment which is a factory for - pictures -rar, zip -reputation -value ... another class... another class... user which has some values -money -energy. ... Now i need to construct a class that would handle all of those data like the scenario user opens a attachment-->attachments receives some values-->user receives some values-->user gets the requested attachment now the user can request many thing not only attachment he can evaulete tags, edit bla bla... Now my dilemma is where the heck shall i store the data? shall i make the object update the DB or shall i store the data in a session.... And one more shall i use a interface to implement all the other sessions or shall i use a abstract class? Link to comment https://forums.phpfreaks.com/topic/192760-how-to-implement-this/ Share on other sites More sharing options...
ohdang888 Posted February 23, 2010 Share Posted February 23, 2010 i believe you can, but its easier to just use the same class (and form what you said, it seems pointless to use more than 1 here) but anyways, say we have class "class1" and "class2" class class1 { var $class2; public function TEST(){ echo $this->class2->we_want_this_var; } } class class2{ var $we_want_this_var; } $class1 = new class1; $class2 = new class2; $class2->we_want_this_var = "this is what we want"; $class1->class2 = $class2; // DEFINE this "class2" var stored in "class1" as an instance of class2 (the class); $class1->TEST(); Try that, and then if it works, play around with it Link to comment https://forums.phpfreaks.com/topic/192760-how-to-implement-this/#findComment-1016566 Share on other sites More sharing options...
sangoku Posted February 25, 2010 Author Share Posted February 25, 2010 ehm, i think you are mmisnig the point here.... usfull idea no doubt,, but not in relation to my question. Link to comment https://forums.phpfreaks.com/topic/192760-how-to-implement-this/#findComment-1018177 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.