This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

TheGreener
TheGreener

I am trying to convert

/* SELECT COUNT(id), YEAR(published_at), MONTH(published_at) FROM october.radiantweb_blog_posts Where published = 1 GROUP BY YEAR(published_at), MONTH(published_at) */

To php (and not getting very far)

so far I have:

$this['archiveDateOfPosts'] = Db::table('radiantweb_blog_posts')
->select('id')
->select('YEAR(published_at)')
->select('MONTH(published_at)')
->where('published', '=', 1)
->count();

looking for a pointer on how to convert it!

Last updated

TheGreener
TheGreener

well figured it out... answer was

$value = Db::table('radiantweb_blog_posts')
    ->select(Db::raw('COUNT(id)'),Db::raw('YEAR(published_at)'),Db::raw('MONTH(published_at)'))
    ->groupBy(Db::raw('YEAR(published_at)'), Db::raw('MONTH(published_at)'))
    ->where('published', '=', 1)
    ->get();

Last updated

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.