开发者

Zend_Db_Table Cascade DELETE doesn't work

开发者 https://www.devze.com 2023-02-11 05:01 出处:网络
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

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 Applica开发者_开发技巧tion_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?


Adding numero_atual to primary, solve the problem.

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

精彩评论

暂无评论...
验证码 换一张
取 消