Tuesday, April 27, 2010

how to add a relationship whit other key different to the PK

Hi, i have this tables:

Software
Reviews
Mirror
Requirements
Published

Now, this is the relations:

Software Has Many Reviews
Software Has Many Mirrors
Software HABTM Requirements

Works fine.

The problem is that i need to resume the tables to get a better response from mysql, the reviews tables have text fields and are classified by language, so, for the public site i do a Published table for each language, i mean: language_en language_es language_fr and load the data automatically into that tables...

The Published table is a merge of the Software and Review Table. The PK of Published table is 'id', and is the same number of the reviews table.

I want to establish this relationship: Published.software_id (not the PK) Has Many Mirrors.software_id

The key has a Unique index, the problem is that aparently i can use the foreign_key attribute when declaring the relationship to set the Mirror model field, but i cant set the field that i want to use on the Published model, it uses the PK by default.

Is there a way to force it to use other key different to the PK for the queries?

Currently im using afterFind function and works okey, but dont allows me to use "contain" or "fields".

Hope you can understand me and help me

thanks for you time,

Manolo

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: