Other Entries

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

  1. “Heroin”
    The Velvet Underground & Nico
    The Velvet Underground
    11/17/08 16:26
  2. “All Tomorrow's Parties”
    The Velvet Underground & Nico
    The Velvet Underground
    11/17/08 16:20
  3. “Run Run Run”
    The Velvet Underground & Nico
    The Velvet Underground
    11/17/08 16:16

Last 100 Songs >