a problem about condition of CDbCriteria

I got 4 condition, like A, B, C, D and I want add them by CDbCriteria::addCondition;

how to add them if they got relation like (A AND B) OR (C AND D) ?

thanks for help me :slight_smile:

Like that:


$criteria->addCondition("(A AND B )");

$criteria->addCondition("(C AND D )", 'OR');

The condition in brackets have to be set toghether.

I mean A, B, C, D is a difference condition and each of them need to using CDbCriteria::addCondition to add.

You can use CDbCriteria::mergeWith() for that purpose.

Aha, thanks for your help, I solved this finally.