Hi there,

I played around some more time and now I got the ArticleAuthor example
working with many-to-many relation!
I will describe important steps here, because I think the
documentation of generating n-m relations in Symfony is poor.

Skipped: initialize project (symfony init-project)

* Data model (file schema.yml):

propel:
  _attributes: { noXsd: false }

  article:
    _attributes: { phpName: Article }
    id:
    title:  varchar(255)

  author:
    _attributes: { phpName: Author }
    id:
    name: varchar(255)

  article_author:
    _attributes: { phpName: ArticleAuthor }
    id:
    article_id: { type: integer, required: true, primaryKey: true }
    author_id:  { type: integer, required: true, primaryKey: true }
    _foreignKeys:
      -
        foreignTable: article
        onDelete: cascade
        references:
          - { local: article_id, foreign: id }
      -
        foreignTable: author
        onDelete: cascade
        references:
          - { local: author_id, foreign: id }


* Build model

symfony propel-build-model


* Build sql

symfony propel-build-sql


* Insert sql

symfony propel-insert-sql


* Initialize module called "backend"

symfony init-app backend


* Initialize a backend module for each table

symfony propel-init-admin backend article Article
symfony propel-init-admin backend author Author
symfony propel-init-admin backend article_author ArticleAuthor


* Modify the file apps/backend/modules/article/config/gererator.yml

generator:
  class:              sfPropelAdminGenerator
  param:
    model_class:      Article
    theme:            default

    edit:
      display:        [title, article_author]
      fields:
        article_author: { type: admin_double_list, params:
through_class=ArticleAuthor }


* Clear cache

symfony cc



When you create a new article record, you can choose your authors now.


Good luck with symfony.
It's really great!


Martin




On 4 Dez., 17:25, "Mat" <[EMAIL PROTECTED]> wrote:
> I'd love to know as well, I assumed that Symfony didn't have anything to
> cope with this at the moment and just created the table/code myself, but if
> it does I'd love to hear about it.
>
> Mat
>
> -----Original Message-----
> From: Martin H [mailto:[EMAIL PROTECTED]
> Sent: 04 December 2007 16:16
> To: symfony users
> Subject: [symfony-users] many-to-many Relationships
>
> Hi there,
>
> I'm new to Symfony.
> Before I start my real-live application I want to try how N-M-
> Relations, or Many-to-Many Relations are defined in Symfony.
> The 
> articlehttp://www.symfony-project.org/book/1_0/14-Generators#Many-to-Many%20...
> nships
> describes it a little bit to short.
>
> I still have some questions:
>
> * How do I define the config/schema.yml?
>
> * Do I have to make the relationship-table by myself?
>
> * If yes, how can I refer to this table?
>
> I am trying to recognize the authors/articels example given in chapter
> 14.
>
> Thanks for help.
>
> Martin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to