Copying jos_comprofiler data into another table.

13 years 1 month ago - 13 years 1 month ago #156235 by ignatius2
Hi,

I have been trying to copy data from the jos_comprofiler table into another table using a user ID extracted from the latter table. It does not work.

The script also copies the email from jos_users.

Could you have a look and tell me what could possibly be wrong.

Here are the fields:

jos_comprofiler id field -> "id" or "user_id"
jos_users id field -> "id"
fab_uploads id field -> "user" (target table name and "reference" user ID field)

jos_comprofiler source field -> cb_accountnumber
fab_uploads target field -> account_number
jos_users source field -> email
fab_uploads target field -> user_email

Here is the code (not mine BTW):
<?php
//get a database object
$db =& JFactory::getDBO();

//get the user id value from the submitted fabrik data
$userid = JRequest::getInt('fab_uploads___user');

//query the cb table to get that users data
$db->setQuery("select #__comprofiler.*, #__users.email from #__comprofiler WHERE #__comprofiler.user_id = $userid LEFT JOIN #__users ON #__users.id = #__comprofiler.user_id");

//load the cb user info into the object $cUser
$cUser = $db->loadObject();

$formModel->updateFormData('fab_uploads___account_number', $cUser->cb_accountnumber, true);  
$formModel->updateFormData('fab_uploads___user_email', $cUser->email, true); 
?> 

I am lost.

Thanks

John

Please Log in to join the conversation.

13 years 1 month ago #156251 by heyai
Just a quick question before reviewing your code: have you tested the queries or parts of them using a database management solution like phpMyAdmin? The error messages there usually point me into the right direction, at least you'd know if your queries are correct.

hey-ai - the community for asian guys and non-asian girls

The search bar is your friend, not just decoration!

Please Log in to join the conversation.

13 years 1 month ago - 13 years 1 month ago #156252 by ignatius2
Unfortunately I do not have PHPmyAdmin installed. I use Webmin and Navicat instead.

I am running the query via Fabrik in a "submission plugin" that runs after a form is submitted.

Is there any other way to get a debug report? Should I install PHP my admin?

Thanks

Please Log in to join the conversation.

13 years 1 month ago - 13 years 1 month ago #156255 by krileon
Please see the below tutorial for obtaining a users object through API.

www.allmysocials.com/tutorials/item/232-establishing-user-object

You'll first need to establish the API externally with the below tutorial.

www.allmysocials.com/tutorials/item/231-include-api-externally

I do not suggest using direct database queries, but if necessary please use the below structure based off your query.
"SELECT c.*, u.`email` FROM `#__comprofiler` AS c LEFT JOIN `#__users` AS u ON u.`id` = c.`id` WHERE c.`id` = $userid"

Please enable debug mode and maximum error reporting within Joomla global configuration anytime you're doing any sort of testing, configuration, or implementation. Without doing so you can not see any fatal errors in your code.


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.

13 years 1 month ago #156523 by ignatius2
Thanks Kyle...

My technical background, I am afraid, is not sufficient to allow me to properly understand the content of your tutorial. Could you point me to a resource that could help me build this "necessary" background.

But this me not be doable I admit

Thanks

Please Log in to join the conversation.

13 years 1 month ago - 13 years 1 month ago #156556 by krileon
All such resources can be found on the same site as the tutorial on the right had side concerning Training and Manuals.


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: ignatius2

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.240 seconds

Facebook Twitter LinkedIn