php - Deep Associations works with recursive => 2 but too slow to load -
i have 3 models product having product_family_id
foreign key productfamily , productfamily have customer_id
foreign key customer. putting recursive 2 in product model allow me customer name customer product. slow data vast
tried using bind model below. didn't worked 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') ) ) ));
use containable
the containable behaviour data want without overhead of recursive 2
set in appmodel make apply models @ once , read on docs on how use it
class appmodel extends model { public $actsas = array('containable'); public $recursive = -1; }
for interfaces in application, may not need information model. 1 thing containablebehavior cut down on find() returns.
it possbible set on models use , set recursive -1 right before find (in wich use 'contain') in eyes best practise models
Comments
Post a Comment