Post::getStream PHP Method

getStream() public method

public getStream ( integer $limit = 10, $cacheTime ) : mixed
$limit integer
$cacheTime
return mixed
    public function getStream($limit = 10, $cacheTime)
    {
        $data = Yii::app()->getCache()->get('Blog::Post::Stream');
        if (false === $data) {
            $data = Yii::app()->db->createCommand()->select('p.title, p.slug, max(c.create_time) comment_date, count(c.id) as commentsCount')->from('{{comment_comment}} c')->join('{{blog_post}} p', 'c.model_id = p.id')->where('c.model = :model AND p.status = :status AND c.status = :commentstatus AND c.id <> c.root', [':model' => 'Post', ':status' => Post::STATUS_PUBLISHED, ':commentstatus' => Comment::STATUS_APPROVED])->group('c.model, c.model_id, p.title, p.slug')->order('comment_date DESC')->having('count(c.id) > 0')->limit((int) $limit)->queryAll();
            Yii::app()->getCache()->set('Blog::Post::Stream', $data, (int) $cacheTime);
        }
        return $data;
    }