Pergunta

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?

Foi útil?

Solução

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top