DoctrineMongoDB:如何在文档中设置注释以存储特定结构?
我正在实现一个php类,该类必须对此进行建模:DoctrineMongoDB:如何在文档中设置注释以存储特定结构?,mongodb,doctrine,doctrine-odm,doctrine-mongodb,Mongodb,Doctrine,Doctrine Odm,Doctrine Mongodb,我正在实现一个php类,该类必须对此进行建模: /** @Document */ classMember { /** @String */ protected $fname; /** @String */ protected $lname; /** @String */ protected $email; /** @Int */ protected $cell; /** @String */ protect
/** @Document */
classMember {
/** @String */
protected $fname;
/** @String */
protected $lname;
/** @String */
protected $email;
/** @Int */
protected $cell;
/** @String */
protected $password;
/** @Int */
protected $gender;
/** @Int */
protected $loc = array();
/** ????? */
protected $info;
}
我希望信息字段本身包含此结构:
info Object
[
contact ["phoneNumber1" , "phoneNumber2"] ,
address ["USA, NY 8791 John St."] ,
email ["my@domain.com", "me@site.info"]
]
我应该实现另一个info.php类吗?如果不是,我如何实现它?
感谢您的帮助…
$info
可能会使用映射。然后,嵌入的类将具有联系人
、地址
和电子邮件
字段的映射
如果contact
和email
确实打算分别保存多个电话号码和电子邮件地址,那么我建议使用映射,这是一个未映射值的任意数组。或者,这些可能是与PhoneNumber和Email对象的关系,但这可能是不必要的开销,因为这将需要存储单个字段(我假设)对象的数组,而不是字符串数组
我不知道为什么要将地址
字段表示为字符串数组,但作为地址对象的嵌入多个关系会有好处。地址将有特定字段(例如国家、省/州)。允许用户以单个字符串的形式输入地址可能很方便,但这会使数据管理和验证成为一场噩梦