How to unbind HasAndBelongsToMany
relationship in CakePHP 2.8? I have this model that is connected to Task model (N:M relationship).
class Date extends AppModel
{
public $name = 'Date';
public $displayField = 'rdate';
public $actsAs = array('Containable');
public $hasAndBelongsToMany = array('Task' => array('className' => 'Task'));
public function getCurrentDate()
{
return $this->find('first',
array(
'conditions' => array(
'Date.rdate' => date('Y-m-d')
)
)
);
}
}
I would like to unbind in getCurrentDate()
function this relationship, but $this->recursive = -1;
in this function nor in find()
doesn't work. I need only one record from Date
model but find returns all Tasks in relationship with this model.
Edit#1: Even unbinding model on the fly doesn't work:
$this->unbindModel(
array('hasAndBelongsToMany' => array('Task'))
);
still returns associated model data.