0

Есть моделька со своим scopes, через которую я получаю определенные записи

class MainTsee extends CActiveRecord
{

    public function tableName()
  {
     return '{{main_tsee}}';
  }

  public function scopes() {
        return array(
           'pupular'=>array (
               'order'=>'look_count'
           ), 
        );
    }

Эта моделька связана с другой вот так

class Country extends CActiveRecord
{
   public function tableName()
   {
       return '{{country}}';
   }

  public function rules()
{   //.. some rules  }


public function relations()
{
    // NOTE: you may need to adjust the relation name and the related
    // class name for the relations automatically generated below.
return array( 'see_places'=>array(self::HAS_MANY, 'MainTsee', 'id_country'),

Вопрос как мне получать значения заданные в scopes через связи?

Обычно без связей так получаю MainTsee::model()->popular->findAll(); А как сделать такую выборку используя связи $model->see_places->popular - например

1 ответ 1

-1

Ознакомьтесь с документацией.

Country::model()->with('see_places:popular')->findAll();

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.