SqlDataProvider is a plain sql query. It is also provide pagination and sorting methods.
SqlDataProvider representing data in arrays form. You can use LIMIT, GROUP BY , ORDER BY in the statements.How to use Sql dataprovider in Yii2
$provider = new SqlDataProvider([
'sql' => 'SELECT * FROM customer WHERE id=:id',
'params' => [':id' => 1],
'sort' => [
'attributes' => [
'name' => [
'asc' => ['name' => SORT_ASC, 'username' => SORT_ASC],
'default' => SORT_DESC
],
],
],
'pagination' => [
'pageSize' => 10,
],
]);
// get the customer results
$data = $provider->getModels();
Nice Blog , This is what I exactly Looking for , Keep sharing more blog .
ReplyDeleteHire Yii Framework Team in India