1

I am trying to get the last id from my selected table. I know lastinsertid(); sould work but it keeps returning a 0. What am i doing wrong here?

   public function getlastadded()
{
    $Sql = 'SELECT * FROM agendaevent';
    $Stm = $this->getEntityManager()->getConnection()->prepare($Sql);
    $Stm->execute();

    return $this->getEntityManager()->getConnection()->lastInsertId('id');
}

ps i am working in symfony if that makes a difference.

Laurence
  • 145
  • 10

1 Answers1

2

Try this, friend:

 "SELECT * FROM agendaevent ORDER BY id DESC LIMIT 1"