Hi all,
I have implemented a one-to-many relationship between 2 tables (contests,
contest_winners)
One contest can have many contest_winners
The problem is that when I delete a contest, the child records get deleted
but the parent record does not. It gives the following error:
Fatal error: Call to a member function delete() on a non-object in /..
/application/models/Contests.php.
This is how I have written the individual classes:
class Contests extends Zend_Db_Table_Abstract
{
protected $_name = 'contests';
protected $_dependentTables = array('ContestWinners');
function delete($id)
{
$rowset = $this->find($id);
$current = $rowset->current();
$current->delete();
return true;
}
}
class ContestWinners extends Zend_Db_Table_Abstract
{
protected $_name = 'contest_winners';
protected $_referenceMap = array(
'Winners' => array(
'columns' => array('contests_id'),
//can some one please tell me why we use array here?
'refTableClass' => 'Contests',
'refColumns' => array(id'),
//and here
'onDelete' => self::CASCADE
));
}
Can anyone please look into this?
Any help would be appreciated. Thanks,
Vibhor