我有一个关于Doctrine ODM的简单问题(顺便说一下,这个工具真的很棒!)。
假设你有一个文档如下:
/**
* @Document
*/
class Test
{
/** @Id */
public $id;
/** @WHICHTYPE */
public $field = array();
}
现在我想存储一个类似于关联数组的结构,例如:
array("test" => "test1", "anothertest" => "test2", ......);
在那个类的$field属性中。
对于MongoDB,这没问题,但是在Doctrine中,当我使用例如@Collection或简单地@Field时,仅存储值(例如,在集合映射驱动程序中使用array_values)。因此,存储的值看起来像array("test1", "test2", ....)
有人知道我应该使用哪种Doctrine-ODM映射类型才能在数据库中保留键值对吗?
先感谢您,
Andi(来自德国的问候)