class News extends BaseNews
{
public function save(Doctrine_Connection $conn = null)
{
$this->setUserId($this->getAttribute('user_id'));
return parent::save($conn);
}
}
我怎样才能获得当前保存的新闻ID?我想为会话添加这个,但我不知道我怎么能得到这个?
答案 0 :(得分:1)
从未使用过symfony,但就我所知,你想要这样的东西:
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;
}
}