Reputation: 2494
I have an Order table which has many IPN. However, I am not using cakephp conventions because the IPN table is from Paypal. I want to join the order table's order_num field to the IPN table's custom field. So it would be like: select * from orders left join ipn on orders.order_num = ipn.custom
How do I set up the model relation correctly in models/order.php.
Upvotes: 2
Views: 1442
Reputation: 83279
I believe this should do the trick, assuming I'm correctly understanding the relationship.
class Order extends AppModel {
var $primaryKey = 'order_num';
var $hasMany = array(
'Ipn' => array(
'className' => 'Ipn',
'foreignKey' => 'custom',
),
);
}
class Ipn extends AppModel {
var $belongsTo = array(
'Order' => array(
'className' => 'Order',
'foreignKey' => 'custom',
),
);
}
Upvotes: 3