开发者

copy/archive object in database - Symfony

i would like make copy if i add and edit News.

class News extends BaseNews
{
    public function postSave(){

        $copy = new CopyNews($this);
        $copy->save();
    }

    public function save(Doctrine_Connection $conn = null)
    {
      return parent::save($conn);  
    }
}

but i h开发者_开发问答ave error:

Strict Standards: Declaration of News::postSave() should be compatible with that of Doctrine_Record::postSave() in ...

How can i make this?


All pre- and post- methods receive $event as a parameter. You should rewrite the method as

 public function postSave(Doctrine_Event $event){
    $copy = new CopyNews($event->getInvoker());
    $copy->save();
 }


All you need is within doctrine

$copy = $this->copy()

... and it's documentation :

http://www.doctrine-project.org/documentation/manual/1_2/en/component-overview:record:getting-object-copy

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜