src/TSFlaggedActiveRecord.php
public function applyFlags($criteria, $flags, $operator = 'AND')
    {
        $flagList = $this->cachedFlags();

        $flags = CPropertyValue::ensureArray($flags);

        $newCriteria = new CDbCriteria();
        foreach ($flags as $flag) {
            if (is_string($flag)) {
                if ($invert = ($flag[0] == '!')) {
                    $flag = substr($flag, 1);
                }
                $flagValue = $flagList[trim(strtolower($flag))];
            } else {
                $flagValue = $flag;
            }
            if (empty($flagValue) === false) {
                $equality = $invert ? '=' : '<>';
                $newCriteria->addCondition($this->flagsField . '&' . $flagValue . $equality . '0', $operator);
            }
        }
        $criteria->mergeWith($newCriteria);
        return $criteria;
    }
public function applyFlags($criteria, $flags, $operator = 'AND')
    {
        $flagList = $this->cachedFlags();

        $flags = CPropertyValue::ensureArray($flags);

        $newCriteria = new CDbCriteria();
        foreach ($flags as $flag) {
            if (is_string($flag)) {
                if ($invert = ($flag[0] == '!')) {
                    $flag = substr($flag, 1);
                }
                $flagValue = $flagList[trim(strtolower($flag))];
            } else {
                $flagValue = $flag;
            }
            if (empty($flagValue) === false) {
                $equality = $invert ? '=' : '<>';
                $newCriteria->addCondition($this->flagsField . '&' . $flagValue . $equality . '0', $operator);
            }
        }
        $criteria->mergeWith($newCriteria);
        return $criteria;
    }
public function applyFlags ( $ criteria , $ flags , $ operator = 'AND' ) { $ flagList = $ this -> cachedFlags ( ) ; $ flags = CPropertyValue :: ensureArray ( $ flags ) ; $ newCriteria = new CDbCriteria ( ) ; foreach ( $ flags as $ flag ) { if ( is_string ( $ flag ) ) { if ( $ invert = ( $ flag [ 0 ] == '!' ) ) { $ flag = substr ( $ flag , 1 ) ; } $ flagValue = $ flagList [ trim ( strtolower ( $ flag ) ) ] ; } else { $ flagValue = $ flag ; } if ( empty ( $ flagValue ) === false ) { $ equality = $ invert ? '=' : '<>' ; $ newCriteria -> addCondition ( $ this -> flagsField . '&' . $ flagValue . $ equality . '0' , $ operator ) ; } } $ criteria -> mergeWith ( $ newCriteria ) ; return $ criteria ; }
Apply flags conditions to given criteria
@param CDbCriteria $criteria the criteria to apply flags condition
@param array $flags the array with flags (as flag name or as flag value). Flag name started with '!' is mean 'not flag'
@param string $operator the operator that connect flags conditions
@return CDbCriteria the CDbCriteria object with applied flags conditions
Apply flags conditions to given criteria