Reputation: 1
I need to make query (in search model) where:
Some steps I resolve:
I know how to create 'new column' and see it in the gridview:
$query->select([
'{{tour}}.*',
'(1000 / 'need to add row index' ) as points' //$points
]);
I know how to get a current index, but with active record:
MyModel::find()->andFilterWhere(['>=', 'cumulative_points', $playerPoints])->count();
But I need to combine this query. Anybody can help me? Thanks.
Upvotes: 0
Views: 414
Reputation: 133370
When you need you can express the content of SQL part like literal and then assign the select content you prefer (not using array / hash assignment) this way
$query->select(' tour.*, 1000 / id ) as points' )
Sostantially you can assign to activeQuery select() method exactly the select part of you query ..
http://www.yiiframework.com/doc-2.0/guide-db-query-builder.html
Upvotes: 0