By tylr23 on Monday, 20 April 2020
Posted in General Issues
Likes 0
Views 626
Votes 0
// Solved in thread https://stackideas.com/forums/comment-count-last-x-days //

Hi,

In the most commented post module's helper.php I am trying to get the items of the last 6 days.

I tried with

$query .= ' WHERE b.`created` >= DATE(NOW()) - INTERVAL 6 DAY;


and also tried with

$query .= ' WHERE b.' . $db->quoteName('created') . ' = ' DATE(NOW()) - INTERVAL 6 DAY;


Both lines would end up crashing the site, could you suggest me what the correct syntax is?

Here is the code from the helper.php to which I am adding the line to in the LEFT JOIN query :


$query = 'SELECT a.*, count(b.' . $db->quoteName('id') . ') as ' . $db->quoteName('comment_count');
$query .= ' FROM ' . $db->quoteName('#__easyblog_post') . ' AS a';

if (!$showBlockedUserPosts) {
//exlude blocked users posts
$query .= ' INNER JOIN `#__users` as uu on a.`created_by` = uu.`id` and uu.`block` = 0';
}

$query .= ' LEFT JOIN ' . $db->quoteName('#__easyblog_comment') . ' AS b ON a.' . $db->quoteName('id') . ' = b.' . $db->quoteName('post_id');
$query .= ' WHERE a.' . $db->quoteName('published') . ' = ' . $db->Quote(EASYBLOG_POST_PUBLISHED);
$query .= ' AND a.' . $db->quoteName('state') . ' = ' . $db->Quote(EASYBLOG_POST_NORMAL);
You can try this :


$query .= ' AND DATE_ADD(a.' . $db->quoteName('created') . ', INTERVAL 6 DAY) >= ' . $db->Quote(EB::date()->toMySQL());

·
Monday, 20 April 2020 13:18
·
0 Likes
·
0 Votes
·
0 Comments
·
Great great great ! Thanks a lot for your sharp answer Arlex !!

I think it solves this feature request :
https://stackideas.com/forums/period-for-the-most-popular-and-most-commented-posts-modules-1
·
Monday, 20 April 2020 23:47
·
0 Likes
·
0 Votes
·
0 Comments
·
You are most welcome, we will see if we can include this feature into future version.

Just for your information, I have locked and marked this thread as resolved to avoid confusions in the future. Please start a new thread if you have any other issue in the future so it will be easier for us to manage your inquiries.

Thanks for understanding.
·
Tuesday, 21 April 2020 10:04
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post