activerecord - Yii join tables on column other than PK -


i'm using gallery manager extension has gallery model connected one-to-many relation galleryphotos model (gallery_photo.gallery_id fk gallery.id).

i have products model want join gallery model one-to-one relation.

how define such relation given don't want modify gallery table (to add fk). 1 option thought adding gallery_id field products table point gallery->id how define relationships in products model file?

how define such relation given don't want modify gallery table (to add fk). 1 option thought adding gallery_id field products table point gallery->id how define relationships in products model file?

if use one-to-one relation situation method, can cause developer inherit code wonder why original guy has done that. think not matter right therefore call situation method

assume how works: adding gallery_id field products table point gallery->id

in function relations() of product model

'gallery' => array(self::belongs_to, 'gallery', 'gallery_id') 

in function relations() of gallery model

'product' => array(self::has_one, 'product', 'gallery_id'), 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -