title: How to search with an array in Yii2 search model
body: <pre><code>public function actionIndex()
  {
      $searchModel = new SubjectSearch();
      $searchModel-&gt;search()-&gt;query-&gt;andFilterWhere(['in','subjectID',[1,2,3]]);
      $dataProvider = $searchModel-&gt;search(Yii::$app-&gt;request-&gt;queryParams);
  
      return $this-&gt;render('index', [
          'searchModel' =&gt; $searchModel,
          'dataProvider' =&gt; $dataProvider,
      ]);
  }
  </code></pre>
  
  <p>I've tried different ways like <br></p>
  
  <pre><code>$searchModel-&gt;subjectID = [1,2,3]
  
  $searchModel-&gt;search()-&gt;query-&gt;andFilterWhere(['in','subjectID',[1,2,3]]);
  </code></pre>
  
  <p>But they doesn't work for me.</p>
  
  <p>Actually, ArrayDataprovider might seem to be a better  solution in this case, but Array Dataprovide won't work with filters.</p>
  
  <p>BTW, the real question is to search with ManyToMany Relationship.</p>
  
  <p>many Users to many Groups.<br>
  many Groups to many Subjects.<br></p>
  
  <p>UserGroupTbl contains UserID and GroupID<br>
  SubjectGroup contains SubjectID and GroupID</p>
  
  <p>I'm trying to do that with:</p>
  
  <pre><code>$groups = $appUser-&gt;getGroups();
  $subjectIDs = [];
  foreach ($groups as $group) {
      $subjectIDs[] = $group-&gt;getSubjectIDs
  }
  $searchModel = new SubjectSearch();
  $searchModel-&gt;subjectID = $subjectIDs;
  </code></pre>
  
  <p>But that doesn't work and is certainly not a good method</p>
  
  <p>Please help me a little bit with it.</p>
  
  <p>================Update==============</p>
  
  <pre><code>    $searchModel = new SubjectSearch();
      $searchModel-&gt;subjectID = [1,2];
      $dataProvider = $searchModel-&gt;search(Yii::$app-&gt;request-&gt;queryParams);
  </code></pre>
  
  <p>Result in "Array to string conversion" error.</p>
  
  <pre><code>    $searchModel = new SubjectSearch();
      $dataProvider = $searchModel-&gt;search(Yii::$app-&gt;request-&gt;queryParams);
      $dataProvider-&gt;query-&gt;andFilterWhere(['in','subjectID',[1,2]]);;
  </code></pre>
  
  <p>This method actually worked.
  BTW, do you have a little bit advice about handling many to many searching?</p>