My question is how to build this relation in Yii model:
The table ledger:
|id|target_type|target_id|amount|
sample data would be like:
|1|shop|20|100.00|
|2|member|30|99.50|
as you can see, I am using the target_type as an indicator of which table to link to, while target_id is the id of the linked foreign table.
I tried this but not working
'shop' => array(self::HAS_ONE, 'shop', 'target_id', 'condition'=>'target_type=shop'),