I wanted to select cities depending from countries so i made this code, but the funny things here is that code show me only the id of the countries that's it and he ignores totally the cities query, it doesn't return nothing:

public function ctsAction() {


                $ctry = $this->get('doctrine_mongodb')
                       ->getRepository('indexBundle:Ctes')
                       ->findOneByCountryName($q_country);

                if( !empty($ctry) ) 
                {
                    $search_country = $ctry->getCtryId();

                    $cties_list = $this->get('doctrine_mongodb')
                                   ->getRepository('indexBundle:Cties')
                                   ->findOneByCountryId($ctry);
                }



    }

If u need some other things tell me, from where comes the problem?

有帮助吗?

解决方案

I solved like that:

$result =  array();
$return = array();
$result = $cties_list->toArray();
foreach ($result as $val) {
  array_push($return, $val->getCityName());
};

If there is any other suggestion, don't hesitate

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top