Paul Sloppy
Paul Sloppy

Reputation: 53

method save - get current ID

class News extends BaseNews
{
    public function save(Doctrine_Connection $conn = null)
    {
      $this->setUserId($this->getAttribute('user_id'));

      return parent::save($conn);
    }
}

How can i get here current save News ID? I would like add this for session, but i dont know how can i get this?

Upvotes: 0

Views: 133

Answers (1)

Kamil Dziedzic
Kamil Dziedzic

Reputation: 5032

Never used symfony but as far as I understand you, you want something like this:

class News extends BaseNews
{
    public function save(Doctrine_Connection $conn = null)
    {
      $this->setUserId($this->getAttribute('user_id'));
      $result = parent::save($conn);

      echo $this->getId(); // Your news Id

      return $result;
    }
}

Upvotes: 1

Related Questions