Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.