Hello,

The mapping in my previous reply worked very nicely for me. My only problem 
is that when I delete department, the record in joinTable will be deleted 
too without deleting admin itself as expected, but if I delete admin, the 
record in joinTable is not deleted. I added 'onDelete' => 'cascade',  
inside joinTable too but no success yet. What should I do?



Department.php:
$metadata->mapManyToMany(array('fieldName' => 'admins', 
                               'targetEntity' => 'Admin', 
                               'cascade' => array('persist','merge'), 
                               'mappedBy' => 'departments'
                              )
                         );
Admin.php:
$metadata->mapManyToMany(array('fieldName' => 'departments', 
                               'targetEntity' => 'Department', 
                               'cascade' => array('persist','merge'), 
                               'inversedBy' => 'admins',

                               'joinTable' => array( 'name' => 
'admin_to_departments', 
                                                      'schema' => NULL, 
                                                      'joinColumns' => 
array( 0 => array( 'name' => 'admin_id',
                                                                                
          
'referencedColumnName' => 'admin_id', 
                                                                                
          
'nullable' => true, 
                                                                                
          
'columnDefinition' => NULL, 
                                                                            
),), 
                                                     'inverseJoinColumns' 
=> array( 0 => array( 'name' => 'department_id', 
                                                                                
                
'referencedColumnName' => 'id', 
                                                                                
                
'nullable' => true, 
                                                                                
                
'onDelete' => 'cascade', 
                                                                                
                
'columnDefinition' => NULL, 
                                                                                
     
), ), 
                                                     ), 
                               )
                         );
 

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to