Getter总是返回NULL

时间:2014-01-29 19:56:19

标签: mongodb symfony doctrine-orm

我在symfony2中的mongodb学说,这是Jackass oops,这是我的文件

<?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
}

你认为这里的问题是什么?

1 个答案:

答案 0 :(得分:0)

问题是Memcached,它缓存了模型并且没有识别出新的字段国家!