title: Getting an error Call to a member function getCount() on a non-object
body: <p>i am using sqldataprovider and i am geting a Call to a member function getCount() on a non-object error. i dont know what have i done wrong. below is my controller code</p>
  
  <pre><code> public function actionTicketbookingreport()
      {
      $count = Yii::$app-&gt;db-&gt;createCommand('
                  SELECT COUNT(*) FROM screen_ticket_booking_history WHERE      status=:status
              ', [':status' =&gt; 0])-&gt;queryScalar();
              $dataProvider = new SqlDataProvider([
                  'sql' =&gt; 'SELECT A1.booking_id As Booking_id,
                          A1.booking_date As Booking_date,
                          A2.movie_name As Movie,
                          A3.theatre_name As Theatre,
                          A1.amount As Amount
  
                          FROM 
                          screen_ticket_booking_history A1
  
                          LEFT OUTER JOIN movies A2 ON A1.movie_id=A2.id
                          LEFT OUTER JOIN theatres A3 ON A1.theatre_id=A3.id
                          LEFT OUTER JOIN users_backend A4 ON A3.users_backend_id=A4.id
  
                          WHERE A1.booking_date &gt;= :start_date
                          AND   A1.booking_date &lt;= :end_date
                          AND   A3.users_backend_id = :id',
  
                  'params' =&gt; [':start_date' =&gt; $year_start,':end_date'=&gt;$year_end,':id'=&gt; $userid],
                  'totalCount' =&gt; $count,
              ]);
  
  
              // get the user records in the current page
              $models = $dataProvider-&gt;getModels(); 
               //no dataprovider
  
  
  
  
                      return $this-&gt;render('index',
                          [   'model'             =&gt; $model,
                              'dataProvider'      =&gt; $models,
  
                          ]);
                  }
  </code></pre>