Skip to Content Skip to Menu

How to calculate the result of crc32 function inside a field ?

  • dotcom22
  • dotcom22
  • OFFLINE
  • Posts: 522
  • Thanks: 14
  • Karma: 4
10 years 10 months ago #238983 by dotcom22
hello

I need to get the calculated value using crc32 function of UserId+Email+Username for each user and I wondering how to do that. CB do no have any "Code" field which can help for this task and CB Query field is not adapted for this.

Any clue ?

I use Joomla 3.3.6 - CB 2.0.4 - CBSubs 4 - Several Incubator plugins

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

  • dotcom22
  • dotcom22
  • OFFLINE
  • Posts: 522
  • Thanks: 14
  • Karma: 4
10 years 10 months ago - 10 years 10 months ago #238989 by dotcom22
I make some investigation and it seem is maybe possible to use CB Query field. So I tried to use this:

SELECT CRC32(CONCAT(user_id, email, username)) FROM `jos_comprofiler` WHERE `user_id` = [user_id]

..and to create a delimiter field for output the result but this don't work. What wrong in my query ?

Furthermore I read this on W3schools:

To ensure that you get the correct string representation from the crc32() function, you'll need to use the %u formatter of the printf() or sprintf() function. If the %u formatter is not used, the result may display in incorrect and negative numbers.

But I don't know if this is necessary and if yes, how to add this in the query. Could you help me also with that please?

thank

I use Joomla 3.3.6 - CB 2.0.4 - CBSubs 4 - Several Incubator plugins
Last edit: 10 years 10 months ago by dotcom22.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48477
  • Thanks: 8281
  • Karma: 1443
10 years 10 months ago - 10 years 10 months ago #238993 by krileon
To do it via MYSQL you'd use the below query. This assumes your database supports crc32.

Code:
SELECT CRC32( CONCAT( `id`, `email`, `username` ) ) FROM `#__users` WHERE `id` = '[user_id]'

CB doesn't have a code field so to do it via PHP you'd need to update a field value after profile update and after registration using a Code action in CB Auto Actions. Set the method to PHP and use whatever PHP you need to update the users user object. The alternative is to create a new fieldtype plugin that works like the query field except it can run PHP and return the result as a field value.


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.
Last edit: 10 years 10 months ago by krileon.

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

  • dotcom22
  • dotcom22
  • OFFLINE
  • Posts: 522
  • Thanks: 14
  • Karma: 4
10 years 10 months ago - 10 years 10 months ago #238997 by dotcom22
you rock your query seem to work well :woohoo: :silly: . I forget always user data are not stored in CB but in Joomla.

The alternative is to create a new fieldtype plugin that works like the query field except it can run PHP and return the result as a field value.


You don't have a future plan such this one on Joomlapolis ??

Happy New Year to you

I use Joomla 3.3.6 - CB 2.0.4 - CBSubs 4 - Several Incubator plugins
Last edit: 10 years 10 months ago by dotcom22.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48477
  • Thanks: 8281
  • Karma: 1443
10 years 10 months ago #239000 by krileon

You don't have a future plan such this one on Joomlapolis ??

I do, it's just low on my TODO list. Time wise it's probably just an hour of work as it's a very simple and basic fieldtype plugin. Just busy focusing on CB 2.0. I have to get all active incubator projects upgraded, which is a pretty time consuming task (so far CB Invites and CB Auto Actions is upgraded).


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