Relations (Many_Many) Ignore Defaultscope..!

Hello friends …!

I have the following problem, I have these 3 tables,




tb_A ( id, is_deleted)

tb_B ( id, is_deleted)

tb_AB ( id, A_id, b_id, is_deleted)


DefaultScope

public function defaultScope() {

  return array ('condition' => $this-> getTableAlias ​​(false, false). '. is_deleted = 0');

}

Relationship A:

public function relations () {

     return array ('bs' => array (self :: MANY_MANY, 'B', 'tb_AB (a_id, b_id)'));

   }

Relationship B:

public function relations () {

     return array ('as' => array (self :: MANY_MANY, 'A', 'tb_AB (a_id, b_id)')); 

}



I have made ​​relationships for table A and type B MANY_MANY and I have defined a defaltScope to only those records that I is_deleted = 0, those who have not been eliminated.

So far everything works fine,




$a = A::model()->findByPk($id);

$bs = $a->db;



I returned all have A or B all A that has B, the problem is when I delete some B of A, you just try to delete the relationship without deleting the B completely, only placing is_deleted tb_AB set is_deleted to 1,




$a = A::model()->findByPk($id);

$bs = $a->db;



I should return only those in is_deleted = 0 but not, I returned all who are related.

Any suggestions friends …