title: Yii 2, active record, with
body: <p>how can i get a set of data, based on condition in relation table?</p>
  
  <p>In Yii 1 i could use <code>with()</code> and <code>'on'</code> statement. This doesn't work in Yii 2, or i can't find any good example.
  For example in Yii 1 i could write this:</p>
  
  <pre><code>$criteria = new CDbCriteria();
  $criteria-&gt;with = array('works'=&gt;array('on' =&gt; 'works.user_id=t.id AND (works.work_id=$SOMEVALUE OR ...)'));
  </code></pre>
  
  <p>I tried something like this (<code>userRight</code> is my relation):</p>
  
  <pre><code>Foo::find()-&gt;with(['userRight'=&gt;['on'=&gt;['user_r'=&gt;$this-&gt;id]]]);
  </code></pre>
  
  <p>Is there any solution in Yii 2?</p>