title: yii2 BaseActiveRecord findAll() conditions greater or less than
body: <p>I have country database table (like found in <a href="http://www.yiiframework.com/doc-2.0/guide-start-databases.html#preparing-the-database">the guide</a>) that I test <a href="/questions/tagged/yii2" class="post-tag" title="show questions tagged 'yii2'" rel="tag">yii2</a> development application. I have field <code>population</code> and I want to create a public method in <code>Country</code> model to return all countries of specific population limits. i.e return all countries of population between x and y.</p>
  
  <p>I tried the following:</p>
  
  <pre><code>// models/Country.php
  ....
  
  public function getPopulationBetween($lower, $upper)
  {
    return Country::findAll(['population' =&gt; ["&gt;=".$lower, "&lt;=".$upper]]);
  
  }
  </code></pre>
  
  <p>In the CountryController:</p>
  
  <pre><code>public function actionGetBetween($lower, $upper)
      {
        print_r(Country::getPopulationBetween($lower, $upper));
      }
  </code></pre>
  
  <p>It returns an empty array i,e <code>Array ()</code></p>
  
  <p>Now I need to know how to set the condition of <code>findAll</code> to be like the SQL condition <code>... Where population &gt;= 20000 AND population &lt;= 40000000</code> i.e How to add comparison to the condition with using an array?!</p>
  
  <p><em>Another side -or optional- question,</em> Why in Country.php when calling <code>findAll</code> as follows:</p>
  
  <pre><code>public function getPopulationBetween($lower, $upper)
      {
        return $this-&gt;findAll(['population' =&gt; ["&gt;=".$lower, "&lt;=".$upper]]);
  
      }
  </code></pre>
  
  <p>It returns an error:</p>
  
  <blockquote>
    <p><strong>Unknown Method – yii\base\UnknownMethodException</strong></p>
    
    <p>Calling unknown method: app\controllers\CountryController::findAll()</p>
  </blockquote>
  
  <p>In other words why must it called statically?</p>