I have 3 models Product having product_family_id
as foreign key to ProductFamily and ProductFamily have customer_id
as foreign key to Customer.
Putting recursive to 2 in Product model allow me to get Customer name from Customer for a product. But its too slow as data is vast
Tried Using Bind model as below. Didn't worked for me. Using Cakephp framework.
$this->Product->bindModel(array(
'belongsTo' => array(
'ProductFamily' => array(
'foreignKey' => false,
'conditions' =>
array('Product.product_family_id = ProductFamily.id')
),
'Customer' => array(
'foreignKey' => false,
'conditions' =>
array('ProductFamily.customer_id = Customer.id')
)
)
));