The many-to-many relationship also means that you have a parent-child
relationship from your $model row object to the table class for the
intersection table (e.g. IntersectTbl).  So you can get a rowset through
that relationship and remove the rows.

  foreach ($model->findIntersectTbl() as $row) {
    $row->delete();
  }

Note this is convenient to code, but it prepares and executes one SQL
statement per matching row in the intersection table.  You need to judge
whether efficiency is more important than convenience in your case.

Regards,
Bill Karwin


Aljosa Mohorovic-3 wrote:
> 
> is there a better way to remove many-to-many relationship, not
> records, but relation in intersection table?
> 
> $db = $model->getTable()->getAdapter();
> $db->delete("intersect_tbl", "item1_id=".$model->id);
> 
> Aljosa
> 
> 

-- 
View this message in context: 
http://www.nabble.com/remove-many-to-many-relationship-tf4962690s16154.html#a14222536
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to