HI
You can take my example and make yaml based the second option, please

Ideally the first option, now only a question what is the reason that
the first is not possible to have extra columns?

2014/1/7 Jasper N. Brouwer <[email protected]>:
> You have 2 options:
>
> 1) User <- ManyToMany -> Group, where the join-table does _not_ have extra
> columns.
>
> 2) User <- OneToMany -> Membership <- ManyToOne -> Group, where Membership
> can have as many extra properties (and even other associations) as you like.
>
> You'll have to choose!
>
>
> --
> Jasper N. Brouwer
> (@jaspernbrouwer)
>
> Sent with my phone, so might be a bit brief.
>
> On 07 Jan 2014, at 18:50, Sandro Cândido <[email protected]>
> wrote:
>
> Hi
>
> Sorry for the insistence that I need is this use case
> http://docs.doctrine-project.org/en/latest/reference/association-mapping.html#many-to-many-unidirectional
> where table "users_groups" has extra columns created when running yaml php
> doctrine orm:schema-tool:create
>
> users_groups to create the table with extra columns and relationships with
> the users and group tables
>
> NEW SAMPLE
>
> Running yaml php doctrine orm:schema-tool:create
>
> CREATE TABLE User (
>     id INT AUTO_INCREMENT NOT NULL,
>
>   name varchar(100) DEFAULT NULL
>
>   password varchar(64) DEFAULT NULL
>
>     PRIMARY KEY(id)
> ) ENGINE = InnoDB;
>
> yaml "users_groups" as this would be, this is what I need. The yaml I did
> not create the database with the ternary relationship and the extra columns
>
> CREATE TABLE users_groups (
>     id INT AUTO_INCREMENT NOT NULL,
>
>   lorem_ipsum varchar(100), "columm extra"
>
>   lorem_ipsum varchar(100), "columm extra"
>
>     user_id INT NOT NULL,
>     group_id INT NOT NULL,
>     PRIMARY KEY(id)
> ) ENGINE = InnoDB;
>
> CREATE TABLE Group (
>     id INT AUTO_INCREMENT NOT NULL,
>
>   name varchar(100) DEFAULT NULL
>
>   description varchar(64) DEFAULT NULL
>
>     PRIMARY KEY(id)
> ) ENGINE = InnoDB;
>
>
>
> Em terça-feira, 7 de janeiro de 2014 13h49min03s UTC-2, Jàπ (Jasper N.
> Brouwer) escreveu:
>>
>> This looks correct :)
>>
>> Please remember that in this case there is _no_ direct association between
>> Person and Company, as the relationship is established through Job.
>>
>> If you like you can add a proxy method to fetch all Companies from a
>> Person:
>>
>>     class Person
>>     {
>>         // ...
>>
>>         public function getCompanies()
>>         {
>>             return array_map(
>>                 function ($job) {
>>                     return $job->getCompany();
>>                 },
>>                 $this->jobs
>>             );
>>         }
>>
>> --
>> Jasper N. Brouwer
>> (@jaspernbrouwer)
>>
>>
>> On 7 Jan 2014, at 15:15, Sandro Cândido <[email protected]> wrote:
>>
>> > Hi
>> >
>> > Below is a template to create annotation and database, in this model to
>> > perform the job CLI php doctrine orm:generate-entities /var/www/project
>> > --generate-annotations=true after php doctrine orm:schema-tool:create 
>> > you'll
>> > see that the job does not add table relationship with the company table. I
>> > need a many to many relationship with the job table that is has the extra
>> > columns
>> >
>> > YAML:
>> >
>> > person\models\entities\Person:
>> >     type: entity
>> >     repositoryClass: person\models\entities\PersonRepository
>> >     table: person
>> >     indexes:
>> >         name_person_index:
>> >             columns: [ name ]
>> >     fields:
>> >         id:
>> >             id: true
>> >             type: integer
>> >             generator:
>> >                 strategy: IDENTITY
>> >         name:
>> >             type: string
>> >             length: 200
>> >             nullable: false
>> >         birth_date:
>> >             type: date
>> >             nullable: false
>> >         email:
>> >             type: string
>> >             length: 80
>> >             nullable: true
>> >         username:
>> >             type: string
>> >             length: 60
>> >             nullable: false
>> >         password:
>> >             type: string
>> >             length: 64
>> >             nullable: false
>> >     oneToMany:
>> >         jobs:
>> >             targetEntity: person\models\entities\Job
>> >             mappedBy: person\models\entities\Person
>> >             cascade: ["persist", "merge"]
>> >
>> >
>> > ------------------------------------------------------------------------------------------------------------
>> > person\models\entities\Job:
>> >     type: entity
>> >     repositoryClass: person\models\entities\JobRepository
>> >     table: job
>> >     fields:
>> >         id:
>> >             id: true
>> >             type: integer
>> >             generator:
>> >                 strategy: IDENTITY
>> >         begin_salary:
>> >             type: integer
>> >             nullable: false
>> >         monthly_salary:
>> >             type: integer
>> >             nullable: false
>> >         begin_job_date:
>> >             type: date
>> >             nullable: false
>> >         resignation_date:
>> >             type: date
>> >             nullable: false
>> >     manyToOne:
>> >         company:
>> >             targetEntity: person\models\entities\Company
>> >             joinColumn:
>> >                 name: company_id
>> >                 referencedColumnName: id
>> >     manyToOne:
>> >         company:
>> >             targetEntity: person\models\entities\Person
>> >             joinColumn:
>> >                 name: person_id
>> >                 referencedColumnName: id
>> >
>> >
>> > --------------------------------------------------------------------------------------------------------
>> >
>> > person\models\entities\Company:
>> >     type: entity
>> >     repositoryClass: person\models\entities\CompanyRepository
>> >     table: company
>> >     indexes:
>> >         name_company_index:
>> >             columns: [ name ]
>> >     fields:
>> >         id:
>> >             id: true
>> >             type: integer
>> >             generator:
>> >                 strategy: IDENTITY
>> >         name:
>> >             type: string
>> >             length: 200
>> >             nullable: false
>> >         description:
>> >             type: text
>> >             nullable: false
>> >     oneToMany:
>> >         jobs:
>> >             targetEntity: person\models\entities\Job
>> >             mappedBy: person\models\entities\Person
>> >             cascade: ["persist", "merge"]
>> >
>> > Em terça-feira, 7 de janeiro de 2014 06h14min34s UTC-2, Jàπ (Jasper N.
>> > Brouwer) escreveu:
>> > Hi Sandro,
>> >
>> > My blog posts describe how to manage such a use-case, but uses
>> > annotations to keep it simple.
>> >
>> > You can have a look at the docs [1] and yaml driver [2] to translate the
>> > annotations to yaml.
>> >
>> > [1]:
>> > http://docs.doctrine-project.org/en/latest/reference/yaml-mapping.html
>> > [2]:
>> > https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php
>> >
>> > --
>> > Jasper N. Brouwer
>> > (@jaspernbrouwer)
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "doctrine-user" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/doctrine-user/9RkFRG9E9U8/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/doctrine-user.
> For more options, visit https://groups.google.com/groups/opt_out.



-- 
   Atenciosamente,

:. Sandro C. Oliveira .:

- Desenvolvedor Web -
PHP/xHtml/jQuery/CSS/CodeIgniter
Brasil +55 (0**62) 3588-5296 / 8585-7666

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to