Below is the code I'm using to get data from my table(s) for creating REST api.
$query = new yii\db\Query();
$sql = $query
->select('a.vehicle_number, b.device_id, b.dated, b.speed, b.ignition, b.latitude, b.longitude')
->from('tk103_devices a, tk103_current_location b')
->where('a.device_id = b.device_id AND a.transporter_id='.$id)
->orderBy(['a.vehicle_number'=>SORT_ASC])
->limit(1);
$dataProvider = new ActiveDataProvider([
'query'=>$sql
]);
return array('count_flag'=>$countFlag, 'dataProvider'=>$dataProvider->getModels());
I had set the limit(1) which does "Sets the LIMIT part of the query." as per Yii official doc http://www.yiiframework.com/doc-2.0/yii-db-querytrait.html#limit()-detail.
When I am executing the above query, all the records are being returned by the dataprovider.
What's wrong with my code?