Hi
I create a cb field query to test if a user have visited a profil after 1 day (return 0 or 1)
( SELECT COUNT(*) FROM `#__comprofiler_views` AS v WHERE v.`profile_id`= '[user_id]' AND v.`viewer_id` = '[cb:userdata field="user_id" user="#me" /]' AND (TO_DAYS(current_timestamp) - TO_DAYS(v.`lastview`)) > 0)
There's no way that 1:1 works in phpMyAdmin due to the prefix and substitution which neither would process in phpMyAdmin. The below example provides the flexibility of telling you how many days since the users last visit.
Code:
SELECT DATEDIFF( NOW(), `lastview` ) FROM `#__comprofiler_views` WHERE `profile_id` = '[user_id]' AND `viewer_id` = '[cb:userdata field="user_id" user="#me" /]'
Example results as follows.
Date: 2015-03-09 14:31:30
Difference: 23 Days
Result: 23
Please understand we do not provide custom coding here. We are not here to write custom code or debug your custom coding for you. I've already informed you of this multiple times. Future requests will be ignored or deleted. We've no issues providing simple examples to get you started, but we're not here to provide you with specific code.
When using a plugin like CB Query Field which simply sends your string through SQL you are expected to debug your own code. It's simply a tool to pass your string along to MYSQL functions and nothing more; it not functioning is guaranteed to be a problem with the query directly. As always be sure debug mode and maximum error reporting is set in Joomla global configuration while testing so you can see error output if the query should fail as well as allows you to debug the query being sent to MYSQL in Joomlas debug display at the bottom of the page.
If you need custom coding you should consult with a contract developer as needed.
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.