Yii’s document is limit,I have a problem with the relations:
I have a trade table and a item table,
trade.item_id refers to item.item_id
but as our app is so complex that item_id can be null sometimes,so I can’t define it as a Primary Key,and we have an auction_id column in item too ,which make it worse for AR to regnize…
the structure is like this:
item(auction_id char(32) not null unique key,item_id bigint default null unique key)
I define a relation in trade:
return array(
'item' => array(self::BELONGS_TO, 'Item', 'item_id','joinType'=>'JOIN'),
);
and I want sql something like :
select * from trade join item on trade.item_id=item.item_id
but what I get is:
select * from trade join item on trade.item_id = item.auction_id
just because the auction_id is placed before item_id…
and I read the document again and again , sometimes read through the RAW code of Yii framework,but still can’t find anything to modify this behavior…
Can’t I define which column to be joined by myself??
I don’t want the too “smart” AR behavior…
Can someone help me?