1
我有一个对象,表示用户在我的网站上的帐户,以及一个独立的对象,充当主帐户对象的附件,并扩展了用户在网站上运行一些主要功能的能力 - 一个功能齐全的店面。根据加载顺序允许对象存储在对方中可以吗?
我一直代表的关系像这样:
Class Account {
$id
$store // this is the store object
$email
$password
$status
get_store() // loads the store
}
Class Store {
$id // unique store id
$store_name
$store_info
post_item()
}
到目前为止,这一直很好,但是当我搜索或集合店这种方式,它需要我去通过账户对象来获取到商店。
我想通过商店能够访问账户对象,将流程减半。
它是否也创建了一个问题,也允许一个$ account对象存储在$ store对象中,以防万一我想以另一种方式加载它?
允许这种双向负荷将如下的例子:
Class Account {
$id
$store // this is the store object
$email
$password
$status
get_store() // loads the store
}
Class Store {
$id
$account // this is the account object
$store_name
$store_info
get_account() // loads the account
post_item()
}
它是用PHP,你需要管理的返回指针的情况下?或者这是一种不同的语言?谢谢阅读! – johnnietheblack
@johnnie双向意味着A有一个B有一个A,所以它不依赖于语言。 – Gordon