Log
bindModel() Only Lasts for One Query
I figured this one out after looking at Ticket #518 in CakePHP’s trac system.
Associations set with bindModel () are removed after a query on the primary model. For instance, if you have a model Event and you bind the model Contact with a HABTM association to it, you can call
$this->Event->Contact->findAll ();
and then
$this->Event->read (null, $id);
and still get the Contact data. But if you then try to call
$this->Event->save ($this->params['data']);
the association will have been removed by the read () query. So if you need to perform two queries on Event that need to do something with Contact data, you need to call bindModel before each query.
04/13/06 09:07AM CakePHP
Recently Played on iTunes
-
“My Sharona”
Frat Rock: The '70s
The Knack
06/04/11 09:27 -
“The KKK Took My Baby Away”
Anthology
The Ramones
06/04/11 09:25 -
“My Sharona”
Frat Rock: The '70s
The Knack
06/04/11 09:24