Arnab
Arnab

Reputation: 4356

Unbind all Models in CakePHP

Is there any function to unbind all associative Models before find() in CakePHP?

$this->Model1->unbindModel(array('hasMany'=>array('Model2'),'belongsTo'=>array('Model3')));

I want to get result from Model1 only. But as I have many models, so I don't want to use unbindModel like this separately.

Upvotes: 0

Views: 2478

Answers (2)

Fury
Fury

Reputation: 4776

Simply set the model recursive to -1

$this->ModelName->recursive = -1;
$assets = $this->ModelName->find('all');
debug($assets);

Upvotes: 5

Amir Hossain
Amir Hossain

Reputation: 693

Just use

$this->Model1->recursive = -1;

Upvotes: -1

Related Questions