我在symfony2中使用MongoDB教义,这是Jackass oops,这是我的文档
<?php
// srcng/NearBundle/Document/Cities.php
namespace ngNearBundleDocument;
use DoctrineODMMongoDBMappingAnnotations as MongoDB;
/**
* @MongoDBDocument(collection="cities") *
*/
class Cities
{
/**
* @MongoDBId
*/
protected $id;
/**
* @MongoDBstring
*/
protected $country;
/**
* @MongoDBstring
*/
protected $name;
/**
* @MongoDBstring
*/
protected $tokens;
/**
* @MongoDBfloat
*/
protected $latitude;
/**
* @MongoDBfloat
*/
protected $longitude;
/**
* Get id
*
* @return id $id
*/
public function getId()
{
return $this->id;
}
/**
* Set country
*
* @param string $country
* @return self
*/
public function setCountry($country)
{
$this->country = $country;
return $this;
}
/**
* Get country
*
* @return string $country
*/
public function getCountry()
{
return $this->country;
}
/**
* Set name
*
* @param string $name
* @return self
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string $name
*/
public function getName()
{
return $this->name;
}
/**
* Set tokens
*
* @param string $tokens
* @return self
*/
public function setTokens($tokens)
{
$this->tokens = $tokens;
return $this;
}
/**
* Get tokens
*
* @return string $tokens
*/
public function getTokens()
{
return $this->tokens;
}
/**
* Set latitude
*
* @param float $latitude
* @return self
*/
public function setLatitude($latitude)
{
$this->latitude = $latitude;
return $this;
}
/**
* Get latitude
*
* @return float $latitude
*/
public function getLatitude()
{
return $this->latitude;
}
/**
* Set longitude
*
* @param float $longitude
* @return self
*/
public function setLongitude($longitude)
{
$this->longitude = $longitude;
return $this;
}
/**
* Get longitude
*
* @return float $longitude
*/
public function getLongitude()
{
return $this->longitude;
}
}
在我的控制器中运行查询时,我会得到这个:
object(ngNearBundleDocumentCities)#226 (6) {
["id":protected]=>
string(24) "52e95b6f69eb53d8877f44b5"
["country":protected]=>
NULL
["name":protected]=>
string(4) "Yuma"
["tokens":protected]=>
string(132) "Juma,YUM,Yuma,you ma,yuma,ywma, aryzwna,ywmh,Јума,Юма,יומה,یوما، آریزونا,ዩማᥠአሪዞና,ユマ,尤馬"
["latitude":protected]=>
string(8) "32.72532"
["longitude":protected]=>
string(9) "-114.6244"
}
国家总是无效的mongodb文档示例:
{
"_id" : ObjectId("52e95b6469eb53d8877eec0c"),
"name" : "'Ali Sabieh",
"tokens" : "Ali Sabie,Ali Sabiet,Ali Sabih,Ali Sabiè,Ali-Sabie,`Ali Sabieh,`Ali Sabih,Али-Сабие,‘Ali Sabieh,‘Ali Sabîẖ",
"country" : "DJ",
"latitude" : 11.15583,
"longitude" : 42.7125
}
您认为这里的问题是什么?
问题是备忘录,它缓存了模型,没有识别新的现场国家!