我不确定如何在 Mongo 中使用 @Collection 注释。如您所知,我正在尝试在 Mongo 文档中保存一个简单的数组。
所以在我的文档中:
/**
* @MongoDB\Collection
*/
protected $counties = array();
/**
* Set counties
*
* @param collection $counties
* @return self
*/
public function setCounties($counties)
{
$this->counties = $counties;
return $this;
}
/**
* Get counties
*
* @return collection $counties
*/
public function getCounties()
{
return $this->counties;
}
现在,当我去保存一些东西时:
$county = "test entry"
$obj = new Obj();
$obj->setCounties(array($county));
它现在给我警告“预期收集,得到数组”。
怎么来的?