Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

[SOLVED] how to ensure the result of the query

  • krileon
  • krileon
  • ONLINE
  • Posts: 48464
  • Thanks: 8280
  • Karma: 1443
11 years 4 months ago #229674 by krileon
Replied by krileon on topic how to ensure the result of the query
You'd need to update your SELECT query to only count the views in the last 3 days from the current day. That way any view that's older than 3 days from current day isn't counted and if there is none it'd return 0. You don't need to reset anything.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • mfe13
  • mfe13
  • OFFLINE
  • Posts: 572
  • Thanks: 26
  • Karma: 5
11 years 4 months ago #229681 by mfe13
Replied by mfe13 on topic how to ensure the result of the query
Not work, My query is:
Code:
SELECT COUNT(viewer_id) AS nombrevisiteurs FROM #__comprofiler_views WHERE profile_id=[user_id] AND DAY(NOW()) - DAY(lastview) < 3 AND viewer_id!=0 LIMIT 30

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48464
  • Thanks: 8280
  • Karma: 1443
11 years 4 months ago #229688 by krileon
Replied by krileon on topic how to ensure the result of the query
Your query isn't correct. You need to check that lastview is equal to or greater than 3 days from now. Using DAY is just pulling the day value from the datetime value and isn't accurate calculation. The below should work.
Code:
SELECT COUNT(*) FROM `#__comprofiler_views` WHERE `profile_id` = '[user_id]' AND `lastview` >= DATE_SUB( NOW(), INTERVAL 3 DAY ) AND `viewer_id` != 0 LIMIT 30

The above will return the view count for a user as long as the views were logged within the last 3 days from now.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: mfe13

Please Log in or Create an account to join the conversation.

  • mfe13
  • mfe13
  • OFFLINE
  • Posts: 572
  • Thanks: 26
  • Karma: 5
11 years 4 months ago #229698 by mfe13
Replied by mfe13 on topic how to ensure the result of the query
Ok, it work now !
Thank's for all your help ;)

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum