In my PHP project, I have 2 classes named User
& Category
as follows.
class User{
public $Id;
public $Name;
public $Category;
}
class Category{
public $CategoryId;
public $CategoryName;
}
My requirement is to include both CategoryId
& CategoryName
inside the $Category
of the User
when retrieving data.
So when I accessing a User - object
I can get both CategoryId
& CategoryName
of the user.
Thanks.
UPDATE
How to automate this process? When I want to load a User
from the database, I want that User
to load it's Category
details Automatically.
And when I loading a collection of User
s (or all Users from the database), I want that all Users to load their own Category.