Cakephp is one to many custom relationship relationships
I have a table of orders that has many IPNs. However, I am not using cakephp conventions because the IPN table is owned by Paypal. I want to join the order_num field of the orders table in a custom IPN table field. So it would be: select * from orders left join ipn on orders.order_num = ipn.custom
How to set model relationship correctly in models / order.php.
+2
source to share
1 answer
I believe this should do the trick, assuming I understand the relationship correctly.
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',
),
);
}
+3
source to share