2009/4/8 FlyLM [ML] <flylm...@gmail.com>:
> Hello,
>
> I have started my first "real" project with Symfony and I've some
> problems and questions.
>
> 1) I use Doctrine as ORM and I18N Behavior in my "schema.yml" file to
> declare localized fields.
>
> "Localized" tables were generated with a columns named "lang". I would
> like to have a relation between this column "lang" and a table where I
> declared an a available list of languages.
> I didn't found how I can add a foreign key on the "localized" tables.
> How can I do it, is it possible ?
>
>
>
> 2) My schema have some "one-to-one" relations like this :
>
> TableA :
>
> ub_product:
>  actAs:
>    I18N:
>      fields: [label]
>      className: %CLASS%_i18n
>  columns:
>    id: { type: integer(6), primary:true }
>    reference: { type: string(64), notnull:true }
>    label: { type: string(255), notnull:true }
>    is_enable: { type: boolean, default:false, notnull:true }
>    country_id: { type: integer(2), notnull:true }
>    product_type_id: { type: integer(2), notnull:true }
>  relations:
>    ub_country: { onDelete: CASCADE, local: country_id, foreign: id }
>    ub_product_type: { onDelete: CASCADE, local: product_type_id, foreign: id }
>
> TableB :
>
> ub_unit:
>  columns:
>    product_id: { type: integer(6), primary:true }
>    unit_type_id: { type: integer(2), notnull:true }
>    bypass: { type:boolean, default:false, notnull:true }
>    flow_normal: { type: integer(2), notnull:true }
>    flow_max: { type: integer(2), notnull:true }
>  relations:
>    ub_product: { onDelete: CASCADE, local: product_id, foreign: id,
> foreignType: one, foreignAlias: %CLASS% }
>    ub_unit_type: { onDelete: CASCADE, local: unit_type_id, foreign: id }
> ...
>
>
> Tables are correctly generated, but when I want to populate table, I
> get an error : "SQLSTATE[23000]: Integrity constraint violation: 1048
> Column 'id' cannot be null "
> If I let doctrine to generate an additional column "id" as primary key
> (I set product_id as unique), my problem is solved, but I really don't
> like to have a additionnal field. Did I do something wrong, I see I'm
> not alone with this issue, but I didn't found any solution.
>

For my 2) question, I finally found the solution. I had set the flag
"owningSide:true" in the declaration of the relation between the two
tables  like this :

TableB :

ub_unit:
  columns:
    product_id: { type: integer(6), primary:true }
    unit_type_id: { type: integer(2), notnull:true }
    bypass: { type:boolean, default:false, notnull:true }
    flow_normal: { type: integer(2), notnull:true }
    flow_max: { type: integer(2), notnull:true }
  relations:
    ub_product: { onDelete: CASCADE, local: product_id, foreign: id,
foreignType: one, foreignAlias: %CLASS%, owningSide:true }
    ub_unit_type: { onDelete: CASCADE, local: unit_type_id, foreign: id }

> Thanks for your help,
> Sorry for my english
>
> Fabien
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to