1

I need execute following sql in yii 1 application.

select user_group.user_id and user_rights.region_id 
from user_rights inner join user_group on
 user_rights.user_group_id=user_group.user_group_id

and to retrieve only all region_ids and paste it inside array? (e.g

                $regions = array();
                $regions[]='1';
                $regions[]='2';

) How can I do it using foreach(or another way) in yii 1?

1 Answer 1

1

Try with this query: you will get all region_id . You can use as your wish by foreach loop etc.

 Yii::app()->db->createCommand()
    ->select('user_rights.region_id')
    ->from('user_rights')
    ->join('user_group', 'user_rights.user_group_id=user_group.user_group_id')
    ->queryAll();

Also for creating query in Yii please read more here: DOCs

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.