Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top