Zend_Db_Table Cascade DELETE doesn't work

800 views Asked by At

I am developing an application to manage a law office using zend framework 1.10,PHP 5.3 and MySQL, I have made a relationship between two tables and I wanted to do cascade deletion however It doesn't work, I tried all possibilities but nothing...

this is the parent model, refer to all processes

<?php
class Application_Model_ProcessosJudicial extends Zend_Db_table {

    protected $_name = "processos_judicial";
    protected $_dependentTables = array('Application_Model_Partes', 'Application_Model_Andamentos');
    protected $_referenceMap = array(
        'Andamento' => array(
            'columns' => array('numero_atual'),
            'refColumns' => array('numero_atual'),
            'refTableClass' => 'Application_Model_Andamentos',
            'onDelete' => self::CASCADE,
            'onUpdate' => self::RESTRICT
        )
    );    

here is the model which refer to a process's status

class Application_Model_Andamentos extends Zend_Db_table {

    protected $_name = "processos_andamentos_judicial";
    protected $_referenceMap = array(
        'Andamento' => array(
            'refTableClass' => 'Application_Model_ProcessosJudicial',
            'refColumns' => array('numero_atual'),
            'columns' => array('numero_atual'),
            'onDelete' => self::CASCADE,
            'onUpdate' => self::RESTRICT
        )
    );

When I am gonna delete one process it returns me

Notice: Undefined index: numero_atual in C:\htdocs\Advocacia\library\Zend\Db\Table\Abstract.php on line 1197

it delete the process but all process's status keeps on the datebase.

Anybody can see anything wrong?

1

There are 1 answers

0
dextervip On BEST ANSWER

Adding numero_atual to primary, solve the problem.

protected $_primary = array("id", "numero_atual");