Skip to content

Commit

Permalink
small fix for postgresql
Browse files Browse the repository at this point in the history
  • Loading branch information
yupe committed Jan 5, 2014
1 parent 3c7812e commit 6b0205d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions protected/modules/blog/models/Post.php
Expand Up @@ -464,17 +464,17 @@ public function getStream($limit = 10, $cacheTime)

if(false === $data) {
$data = Yii::app()->db->createCommand()
->select('p.title, p.slug, max(c.creation_date) comment_date, count(c.id) commentsCount')
->select('p.title, p.slug, max(c.creation_date) 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', array(
':model' => 'Post',
':status' => Post::STATUS_PUBLISHED,
':commentstatus' => Comment::STATUS_APPROVED
))
->group('c.model, c.model_id')
->group('c.model, c.model_id, p.title, p.slug')
->order('comment_date DESC')
->having('commentsCount > 1')
->having('count(c.id) > 1')
->limit((int)$limit)
->queryAll();

Expand Down
2 changes: 1 addition & 1 deletion protected/modules/blog/widgets/BlogsWidget.php
Expand Up @@ -23,7 +23,7 @@ public function run()
'join' => 'JOIN {{blog_user_to_blog}} utb ON utb.blog_id = t.id',
'select' => 't.name, t.slug, utb.id',
'order' => 'count(utb.id) DESC',
'group' => 't.slug',
'group' => 't.slug, t.name, utb.id, t.id',
'limit' => $this->limit,
));

Expand Down

0 comments on commit 6b0205d

Please sign in to comment.