Answer the question
In order to leave comments, you need to log in
How to make a request to calculate the rating?
Hello everyone, I can not make a correct query in the table to calculate the total number of ratings.
Table fields id | performer_id | review | rateNum
The query itself, you need to calculate in the rateNum column
$countReviews = OrdersHasReviewsRating::find()
->asArray()
->where(['performer_id' => Yii::$app->user->id])
->all();
Answer the question
In order to leave comments, you need to log in
Something like this
$sql = 'SELECT SUM(`rateNum`) as `sum` FROM `' . OrdersHasReviewsRating::tableName() . '` WHERE `performer_id`=:performer_id';
$ratingSummary = Yii::$app->db->createCommand($sql)
->bindValue(':performer_id', Yii::$app->user->id)
->queryScalar(); // или ->queryOne();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question