Jump to content

how to implement this?


sangoku

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.