title: Yii2 how does search() in SearchModel work?
body: <p>Please can someone explain how the <code>search</code> method in a Yii2 <code>SearchModel</code> works? I generated it using Gii. Here it is:</p>
  
  <pre><code>public function search($params){
      $query = MyModel::find();
      $dataProvider = new ActiveDataProvider([
          'query' =&gt; $query,
      ]);
  
      if (!($this-&gt;load($params) &amp;&amp; $this-&gt;validate())) {
          return $dataProvider;
      }
  
      $this-&gt;addCondition($query, 'att1');
      $this-&gt;addCondition($query, 'att1', true);
      $this-&gt;addCondition($query, 'att2');
      $this-&gt;addCondition($query, 'att2', true);
  
      return $dataProvider;
  }
  </code></pre>
  
  <p>This is how I call it:</p>
  
  <pre><code>$search = new MyModelSearch();
  $myModels = $search-&gt;search(['att3' =&gt; '3']);
  </code></pre>
  
  <p>Regardless of what attributes I use in calling <code>search</code>, I always get back the same result - i.e. all the entries in the table. I'm missing something here that I just do not understand.</p>
  
  <p>Any help would be really appreciated. Thanks.</p>