php and database

11 years 8 months ago #208604 by abrbhat
php and database was created by abrbhat
I want to create an auto action such that a field is read from database, some manipulations are performed on it using php and then it is reassigned to some other field. How can i do that?

Please Log in to join the conversation.

11 years 8 months ago #208611 by krileon
Replied by krileon on topic Re: php and database
Just do a Code action with method set to PHP and use Joomla/CB API to do whatever you need. If you were more specific as to your needs you could actually just use a Query action and use database functions to alter the field.


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 to join the conversation.

11 years 8 months ago - 11 years 8 months ago #208618 by abrbhat
Replied by abrbhat on topic Re: php and database
How do I pass values from a php Code action to a Query Code Action and vice-versa?

Please Log in to join the conversation.

11 years 8 months ago #208621 by krileon
Replied by krileon on topic Re: php and database
You don't. They can't communicate with one another. If you need queries and PHP then you need to use a Code action with PHP method and use Joomla or CB API to perform the query using PHP.


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 to join the conversation.

11 years 8 months ago - 11 years 8 months ago #208625 by abrbhat
Replied by abrbhat on topic Re: php and database
Is there a tutorial about use of CB API to perform the query using php.If not, please give a brief example of how to write, say an update query. Do I need to connect to database.
I have tried that before also but did not succeed with it.

To be more specific: I want to run a query and find out the total number of rows affected by it(say x). Then I want to run another query with LIMIT x.

Please Log in to join the conversation.

11 years 8 months ago #208628 by krileon
Replied by krileon on topic Re: php and database

Is there a tutorial about use of CB API to perform the query using php

No.

please give a brief example of how to write, say an update query.

Below is an example of CB API to perform a query.
$query = "YOUR QUERY HERE"
$_CB_database->setQuery( $query );
$_CB_database->query();

Replace "YOUR QUERY HERE" with your database query of course.

Do I need to connect to database.

No.

To be more specific: I want to run a query and find out the total number of rows affected by it(say x). Then I want to run another query with LIMIT x.

Being PHP you can do whatever you want, but based off your needs you should be able to just use a Query action with the LIMIT being a subquery.


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 to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.225 seconds