0

Hi i'm using zend framework and I have a problem on delete cascade.

I have two entity in Zend db table called User and other two (because i have 2 tipe of users) connected to User

User is

class Application_Model_DbTable_User extends Zend_Db_Table_Abstract
{
protected $_name = 'user';
protected $_primary = 'username';    
protected $_dependentTables = array('Cliente','Trainer');
}

One of the other is

class Application_Model_DbTable_Trainer extends Zend_Db_Table_Abstract{
protected $_name = 'trainer';
protected $_primary = 'idusername';

protected $_referenceMap = array(
    'Utente' => array(
        'columns' => array('idusername'), 
        'refTableClass' => 'user', 
        'refColumns' => array('username'),
        'onDelete' => self::CASCADE
    )
);

protected $_dependentTables = array('Trainermaster','Presenza','Uscita');}

When I use the delete option on an object of User, Zend delete only the user in the User table and not in Trainer table...

I have set the delete cascade in mysql database too to be more safe but it doesn't work.

Simone
  • 85
  • 1
  • 9

1 Answers1

0

$_dependentTables must refer to your class names, not your database table names:

protected $_dependentTables = array('Application_Model_DbTable_Cliente',
                                    'Application_Model_DbTable_Trainer');
Liyali
  • 5,643
  • 2
  • 26
  • 40
  • another error is 'refTableClass' => 'user', in which i should write Application_Model_DbTable_User but it doesn't work again...if I use the ->delete($where) zend system delete only in user table...if i use ->_cascadeDelite nothing appen... – Simone Apr 16 '12 at 19:46
  • I'm using the lastest version of mysql...i was using myisiam table with this contrains in Zend_Db_Table. Now I'm trying to delete all the dependent table in zend, and use InnoDb table...i hope this will works. – Simone Apr 17 '12 at 09:51