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
Post a Comment