开发者

versioning on one-to-many relation

i have a little problem with symfony versionable feature in Doctrine one-to-many relationships. i have one-to-many relationship and i want to make it versionable. here is my schemas:

Article:
actAs:
  Versionable:
    versionColumn: version
    className: %CLASS%Version
    auditLog: true
columns:
  title: string(255)
  body: clob

Comment:
  columns:
    body: string(255)
  Article_ID:
    type: integer
    notnull: true
  relations:
    Article:
      onDelete: CASCADE
      foreignAlias: Comments

well, now Article is versionable and will keep versioning but i want to get comments for a specific version of Article too.

for example:

$article= new Article();
$article->title = 'Test blog post';
开发者_如何学Python$article->body = 'test';
//version 1
$article->save();

$article->title = 'ver 2';
//version 2
$article->save();

$comment = new Comment();
$comment->body = 'comment1';
$article->Comments[0] = $comment;
$article->save();

$article->title = 'ver  3';
//version 3
$article->save();

now i have 3 versions of article but only 2nd version of article has 'comment1' and i want to get that comment for only 2nd article. by this schema it will return all comments for all versions of article and it's reasonable because it's looking for related article id not article_version id.

now i dont't know how make it work.

any help will be appreciated.

thanks.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜