title: How to write a subquery in yii2 'where'?
body: <p>I have this query:</p>
  
  <pre><code>select * from dias_clases as dc
  inner join clases as cl on cl.clase_id = dc.clase
  inner join asistencias as asis on asis.dia_clase = dc.dc_id
  where( 
  clase in(select ce.clase from clases_estudiantes as ce where ce.estudiante = 321)
  or dc_id in (select cr.dia_clase from clase_recuperada as cr where cr.estudiante = 321)
  )
  and fecha &lt; '2017-04-26'
  and cl.disciplina = 9
  and dc.estado = 1
  group by dc.dc_id
  order by dc.fecha desc
  </code></pre>
  
  <p>It works fine in the mysql console. I need the same query in Yii2 with the active record and i got this:</p>
  
  <pre><code>$dias_clases = DiasClases::find()
                  -&gt;innerJoin("clases as cl", "cl.clase_id = clase")
                  -&gt;leftJoin("asistencias as asis", "asis.dia_clase = dc_id")
                  -&gt;where("
                      clase in(
                          select ce.clase from clases_estudiantes as ce where ce.estudiante = :estudiante
                      )
                      or dc_id in (
                          select cr.dia_clase from clase_recuperada as cr where cr.estudiante = :estudiante
                      )", [":estudiante" =&gt; $estudiante-&gt;estudiante_id]
                  )
                  -&gt;andWhere("fecha &lt; :fecha", [":fecha" =&gt; $fecha])
                  -&gt;andWhere(["cl.disciplina" =&gt; $disciplina])
                  -&gt;andWhere(["estado" =&gt; DiasClases::TERMINADA])
                  -&gt;orderBy(["fecha" =&gt; SORT_DESC])
                  -&gt;all();
  </code></pre>
  
  <p>But the 'where' is not working properly. The results i get are wrong and i think it is because this part: </p>
  
  <pre><code>where( 
      clase in(select ce.clase from clases_estudiantes as ce where ce.estudiante = 321)
      or dc_id in (select cr.dia_clase from clase_recuperada as cr where cr.estudiante = 321)
      )
  </code></pre>
  
  <p>does'nt executes the same way that in console. The parenthesis is needed</p>