Tuesday, April 28, 2009

dependent has no effect with delete()

I'm using $this->Item->del($id, true) in ItemsController. I expect
that its ItemFiles would also be deleted but they are not. I've
compared my models with the examples in the book several times and
plodded through the source and I've no idea what the problem is.
Anyone else think of something?

class Item extends AppModel
{
public $hasMany = array(
'ItemFile' => array(
'className' => 'ItemFile',
'foreignKey' => 'item_id',
'dependent' => true
)
);
}

class ItemFile extends AppModel
{
public $belongsTo = array(
'Item' => array(
'className' => 'Item',
'foreignKey' => 'item_id'
)
);
}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: