symfony - get the last element in doctrine2/symfony2 -


i have relation manytoone between 2 entity collaborateur , conge.

 /**  * @orm\manytoone(targetentity="collaborateur", inversedby="collaborateur", cascade={"remove"})  * @orm\joincolumn(name="collaborateur_id", referencedcolumnname="id")  */ protected $collaborateur; 

in congemanager have function:

 public function findcongebycollaborateur ($collaborateur){         return $this->getrepository()->findoneby(array('collaborateur'=>$collaborateur));     } 

it return first element of conge want last 1 .

$this->getrepository()->findoneby(          array('collaborateur'=>$collaborateur),          array('id' => 'desc') ); 

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 -