try to call the delete function in your model something else, like
deletebyid($id)...
Vibhor Singh-2 wrote:
>
> 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
>
-----
visit my website at http://www.phpscriptor.com/ http://www.phpscriptor.com/
--
View this message in context:
http://www.nabble.com/Child-rows-get-deleted-but-Parent-does-not-tp22120306p22121297.html
Sent from the Zend Framework mailing list archive at Nabble.com.