Merging defaultScope

Hi, I have two classes, one of which extends the other. On both of them I have defaultScopes() set.

How do I make the second one not override the first one?

Let me show as an example:




Class A {

  (...)

  public function defaultScope()

  {

     return array(

       'condition' => 'some.condition = here'

     );

  }

}


Class B extends A {

  (...)

  public function defaultScope()

  {

    return array(

      'condition' => 'some.other.condition = here'

    );

  }

}



So, when I call B::model()->findAll(), for example, only B’s defaultScope is run.

I could have done




Class B extends A {

  (...)

  public function defaultScope()

  {

    return array_merge(parent::defaultScope(), array(

      'condition' => 'some.other.condition = here'

    ));

  }

}



But that would not work either, since ‘condition’ would get overriden anyway.

Any suggestions as to how can I run both A’s defaultScope() and B’s?

Thanks!




class B extends A

{

	public function defaultScope()

	{

		$criteria = new CDbCriteria(parent::defaultScope());

		$criteria->addCondition('condition');

		return $criteria->toArray();

	}

}



I guess you could just use the CMap::mergeArray function.


public function defaultScope()

{

  return CMap::mergeArray(

    parent::defaultScope(),

    array(

      'condition' => $this->getTableAlias(true, false) . ".yourColumn = 'value'"

    )

  );

}