2014-01-29 247 views
0

我在Symfony2的MongoDB的學說,這是公驢哎呀,這是我的文檔消氣總是返回NULL

<?php 
// srcng/NearBundle/Document/Cities.php 
namespace ng\NearBundle\Document; 

use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB; 

/** 
* @MongoDB\Document(collection="cities") * 
*/ 
class Cities 
{ 
    /** 
    * @MongoDB\Id 
    */ 
    protected $id; 
    /** 
    * @MongoDB\string 
    */ 
    protected $country; 
    /** 
    * @MongoDB\string 
    */ 
    protected $name; 
    /** 
    * @MongoDB\string 
    */ 
    protected $tokens; 
    /** 
    * @MongoDB\float 
    */ 
    protected $latitude; 
    /** 
    * @MongoDB\float 
    */ 
    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(ng\NearBundle\Document\Cities)#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 
} 

你認爲什麼是PROBL他們在這裏?

+0

DB中'country'字段的長度是多少? –

+0

它是2個字符 – Sekai

回答

0

問題是Memcached,它緩存模型,並沒有認識到新的領域的國家!