Ejemplo n.º 1
0
 public function getTopAuthors($numOfAuthors)
 {
     $temp_topAuthors = (new \yii\db\Query())->select(['user_created as author', 'count(*) as cnt'])->from('Posts')->groupBy(['user_created'])->limit(10)->all();
     foreach ($temp_topAuthors as $Author) {
         $userid = $Author['author'];
         $username = PostHelper::getUserName($userid);
         $topAuthors[] = ['userid' => $userid, 'author' => $username, 'cnt' => $Author['cnt']];
     }
     if ($topAuthors) {
         return $topAuthors;
     } else {
         return null;
     }
 }