In the latest Yii releases, the focus was moved from using Active Record directly, to grids, lists, and data providers. Still, sometimes it is better to use Active Record directly. Let's see how to list paginated AR records with the ability to sort them. In this section, we would like to create a list of films and sort them by some attributes from a database. In our example, we will sort our films by film title and rental rate attributes.
Create a new application using the Composer package manager, as described in the official guide at http://www.yiiframework.com/doc-2.0/guide-start-installation.html.
Download the Sakila database from http://dev.mysql.com/doc/index-other.html.
Execute the downloaded SQLs; first schema, then data.
Configure the DB connection in
config/main.phpto use the Sakila database.
Use Gii to create the