Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

i want to use some scope if yii active record model in same model's another scope see the following code, you will understand what i want to say?

public function scopes() {
    return array(
        'avg_all'=>array(
            'select'=>array(
                'avg_fp_1'=>'AVG(CASE when t.fp_1>=0 then t.fp_1 ELSE NULL END)',
                'avg_fp_2'=>'AVG(CASE when t.fp_2>=0 then t.fp_1 ELSE NULL END)',
                'avg_fp_3'=>'AVG(CASE when t.fp_3>=0 then t.fp_1 ELSE NULL END)',
                'avg_fp_4'=>'AVG(CASE when t.fp_4>=0 then t.fp_1 ELSE NULL END)',
                'avg_fp_5'=>'AVG(CASE when t.fp_5>=0 then t.fp_1 ELSE NULL END)',
            ),
        ),
        'avg_feedback'=>array(
            'with'=>array('avg_all'),
            'select'=>array(
                'avg_feedback'=>'ROUND((avg_fp_1+avg_fp_2+avg_fp_3+avg_fp_4+avg_fp_5)/5,2)'
            )
        )
    );
}

main problem 'with'=>array('avg_all'),

is it possible to use another scope inside a scope.

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.