都市レベルで自動提案を作成して、次のようなそれぞれの国にマップされた都市のリストを作成する必要がありますUSA => ( "New York", "Dallas", "Los Angeles" .....)
必要なのは、symfony2 マッピング メソッドを使用して mongodb に保存することです。私はたくさん検索しましたが、mongodb での配列処理に関する適切なヘルプやドキュメントを見つけることができませんでした。
この分野での経験がある場合は説明してください。
namespace SPTL\UserBundle\Document;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
/**
* @MongoDB\Document
*/
class City {
/**
 * @MongoDB\Id
 */
protected $id;
/**
 * @MongoDB\String
 */
protected $country;
/**
 * @MongoDB\hash
 */
protected $city = array();
/**
 * Get id
 *
 * @return id $id
 */
public function getId()
{
    return $this->id;
}
/**
 * Set country
 *
 * @param string $country
 * @return \City
 */
public function setCountry($country)
{
    $this->country = $country;
    return $this;
}
/**
 * Get country
 *
 * @return string $country
 */
public function getCountry()
{
    return $this->country;
}
/**
 * Set city
 *
 * @param hash $city
 * @return \City
 */
public function setCity($city)
{
    $this->city = $city;
    return $this;
}
/**
 * Get city
 *
 * @return hash $city
 */
public function getCity()
{
    return $this->city;
}
}
挿入する使用法:
    $dm = $this->get('doctrine_mongodb')->getManager();
    $cities = new City();
    $cities->setCountry("USA");
    $cities->setCity(array("New York", "Dallas", "Los Angeles"));
    $dm->persist($cities);
    $dm->flush();
挿入されたレコード:
{
 "_id": ObjectId("5252b03f6b0f57394e2fb1b5"),
 "country": "USA",
 "city": {
  "0": "New York",
  "1": "Dallas",
  "2": "Los Angeles"  
  } 
}
取得に使用されるコード:
$repository = $this->get('doctrine_mongodb')->getManager()
    ->getRepository('UserBundle:City');
$cities = $repository->findBy(array("_id"=>'5252b03f6b0f57394e2fb1b5'));
print_r($cities);
しかし、上記の検索コードではレコードを取得できません.....