php - How to use parameters -


lets have url:

/people/1/friends 

both people , friend objects, 1 person can have many friends

friendcontroller looks this

class friendcontroller extends controller {   public function indexaction()   {       $em = $this->getdoctrine()->getmanager();        $entities = $em->getrepository('epiforumbundle:friend')->findall();        return $this->render('epiforumbundle:friend:index.html.twig', array(           'entities' => $entities,       ));   }  } 

this index action works can see returns every friend in database. friends 'people_id' == 1. how can select wanted friends? in other words, how can parameter tells specific person?

update

routes

friend:     pattern:  /     defaults: { _controller: "epiforumbundle:friend:index" } 

first, name param in indexaction - symfony simple contoller

second, use findby() method on repository:

public function indexaction($peopleid) {     $em = $this->getdoctrine()->getmanager();      $entities = $em->getrepository('epiforumbundle:friend')->findby(array(         'people_id' => $peopleid     ));      return $this->render('epiforumbundle:friend:index.html.twig', array(             'entities' => $entities,     )); } 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -