have 2 models.
<?php
class Inventory extends AppModel {
var $name = 'Inventory';
var $validate = array(
'title' => VALID_NOT_EMPTY,
'description' => VALID_NOT_EMPTY,
'cost' => VALID_NOT_EMPTY,
);
//The Associations below have been created with all possible keys,
those that are not needed can be removed
var $hasMany = array(
'Photo' =>
array('className' => 'Photo',
'foreignKey' => 'inventory_id',
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'dependent' => 'true',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
);
}
?>
<?php
class Photo extends AppModel {
var $name = 'Photo';
var $validate = array(
'img' => VALID_NOT_EMPTY,
);
//The Associations below have been created with all possible keys,
those that are not needed can be removed
var $belongsTo = array(
'Inventory' =>
array('className' => 'Inventory',
'foreignKey' => 'inventory_id',
'conditions' => '',
'fields' => '',
'order' => '',
'counterCache' => ''
),
);
}
?>
and in my controller i would like when i do a $this->del has all of
the associated data deleted. here in the function in my controller.
<?php
class InventoriesController extends AppController {
var $name = 'Inventories';
var $uses = array('Inventory', 'Photo');
var $helpers = array('Html', 'Form' );
function admin_delete($id = null) {
if(!$id) {
$this->Session->setFlash('Invalid id for Inventory');
$this->redirect('/admin/inventories/index');
}
if($this->Inventory->del($id, $cascade=true)) {
$this->Session->setFlash('The Inventory deleted: id
'.$id.'');
$this->redirect('/admin/inventories/index');
}
}
}
?>
do i have my dependent keys set properly in my models? and is the
$cascade option properly being passed in my delete function?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---