Skip to Content Skip to Menu

Need help with SQL in CB Queries

  • apdt
  • apdt
  • OFFLINE
  • Posts: 104
  • Thanks: 2
  • Karma: 3
12 years 2 months ago #194490 by apdt
Need help with SQL in CB Queries was created by apdt
I want to set a dropdown field 'cb_logousage' to a certain value upon registration, depending on member's plan and if they check a checkbox 'cb_applylogo'.

I did a test using simple SQL as follows and it works:
Code:
UPDATE jos_comprofiler c LEFT JOIN jos_cbsubs_subscriptions s ON c.user_id = s.user_id SET c.cb_logousage = 'Pending Approval' WHERE c.user_id = [user_id] AND c.cb_applylogo = 1;

The above code set the field 'cb_logousage' correctly. Then I add more condition to limit by plan ID and it doesn't work anymore:
Code:
UPDATE jos_comprofiler c LEFT JOIN jos_cbsubs_subscriptions s ON c.user_id = s.user_id SET c.cb_logousage = 'Pending Approval' WHERE c.user_id = [user_id] AND c.cb_applylogo = 1 AND s.plan_id = 1;

Basically everytime I add condition from table jos_cbsubs_subscriptions the SQL stops working. I copy-paste the SQL to phpMyAdmin (supplying user_id manually) and it works.

Perhaps anyone can spot something I missed?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 68613
  • Thanks: 9109
  • Karma: 1434
12 years 2 months ago #194513 by krileon
Replied by krileon on topic Re: Need help with SQL in CB Queries
CB Queries is depreciated, please upgrade to CB Auto Actions. If you need this for CBSubs then you should add it directly to the plan that you want it applied to using CBSubs SQL Actions. Due to the order of execution it's likely the plan is not becoming active or inserted into database at the time you're executing your query.


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.

  • apdt
  • apdt
  • OFFLINE
  • Posts: 104
  • Thanks: 2
  • Karma: 3
12 years 2 months ago #194529 by apdt
Replied by apdt on topic Re: Need help with SQL in CB Queries
I think you're right, the trigger was executed before subscription record was created. I'm moving the SQL to Integrations > SQL Actions now.

Another question, what triggers 'Deactivation' in CBSubs > Integration > SQL Actions? Must it be triggered from the front-end? I tried to set subscriptions to Inactive and Unsubscribed at backend but the deactivation SQL was not executed.

Does CB Auto Actions work with CBSubs 1.1.2 and CB 1.4? I know that ideally both should be upgraded but it's up to my client to decide.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 68613
  • Thanks: 9109
  • Karma: 1434
12 years 2 months ago #194530 by krileon
Replied by krileon on topic Re: Need help with SQL in CB Queries

Another question, what triggers 'Deactivation' in CBSubs > Integration > SQL Actions? Must it be triggered from the front-end? I tried to set subscriptions to Inactive and Unsubscribed at backend but the deactivation SQL was not executed.

Editing a subscription from CBSubs > Subscriptions won't fire triggers. It's a direct database edit. To have triggers you'll need to edit them from CB > User Management and expire them properly.

Does CB Auto Actions work with CBSubs 1.1.2 and CB 1.4? I know that ideally both should be upgraded but it's up to my client to decide.

Nope, you should upgrade both. I recommend stressing the importance of maintaining up to date releases to your client. At any rate I can't guarantee what will and will not work on your releases unfortunately as both are quite significantly out of date.


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.

  • apdt
  • apdt
  • OFFLINE
  • Posts: 104
  • Thanks: 2
  • Karma: 3
12 years 2 months ago #194532 by apdt
Replied by apdt on topic Re: Need help with SQL in CB Queries

krileon wrote: Editing a subscription from CBSubs > Subscriptions won't fire triggers. It's a direct database edit. To have triggers you'll need to edit them from CB > User Management and expire them properly.

I tried that as well, setting the user to 'Unsubscribed' but the SQL didn't fire either. I'll try again. But I don't see option to expire the user in the User Management, only 'Unsubscribe' and 'Delete'. How do I manually expire a user?

Nope, you should upgrade both. I recommend stressing the importance of maintaining up to date releases to your client. At any rate I can't guarantee what will and will not work on your releases unfortunately as both are quite significantly out of date.

Yeah, I guess that's on their to-do list. We did talk about it before.

When we upgrade, will the current plugins still work? Otherwise we need to shut down the site until I'm done migrating whatever it is that needs to be migrated (like CB Queries to Auto Actions, etc).

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 68613
  • Thanks: 9109
  • Karma: 1434
12 years 2 months ago #194579 by krileon
Replied by krileon on topic Re: Need help with SQL in CB Queries

I tried that as well, setting the user to 'Unsubscribed' but the SQL didn't fire either. I'll try again. But I don't see option to expire the user in the User Management, only 'Unsubscribe' and 'Delete'. How do I manually expire a user?

Unsubscribed should do the trick, but believe you'll need to setup your usages to use the Cancelled usage instead of just Expired. For example with SQL Actions you'll want to setup "Deactivation".

When we upgrade, will the current plugins still work? Otherwise we need to shut down the site until I'm done migrating whatever it is that needs to be migrated (like CB Queries to Auto Actions, etc).

Don't know what all you've installed, but they should still work; I can't make any guarantee for depreciated projects though as I didn't test them on CB 1.8.


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.

Moderators: beatnantkrileon
Powered by Kunena Forum

Facebook Twitter LinkedIn