How to do this complex join with AR?

Hi,

I have a table called: MMoipTransactions and other table called: MPaymentOrder.

I want make a join that brings only one item of MMoipTransactions in MPaymentOrder with relation type: BELONGS_TO.

The columns for reference is:

MMoipTransactions.object_id = MPaymentOrder.id (object_id is not the primary key)

And i try do it with my code (in the model MPaymentOrder):


public function relations()

{

	return array(

		'moipTransaction' => array(self::BELONGS_TO, 'MMoipTransactions', 'id', 'joinType' => 'INNER JOIN'),

	);

}

But the ON clausule of JOIN is wrong, and i need say to the relation that i need join MMoipTransactions.OBJECT_ID with MPaymentOrder.ID.

How i can rewrite the ON clausule of JOIN, because when i try change it concat on WHERE clausule.

I think it would be more straightforward to have FK transaction_id in MPaymentOrder.

Anyway, it’s possible to avoid the multipart ON condition by passing ‘’ (empty string) instead of ‘id’ as the FK.

/Tommy