Skip to Content Skip to Menu

[SOLVED] Error is display list with regex

  • comyoo
  • comyoo
  • OFFLINE
  • Posts: 87
  • Thanks: 1
  • Karma: 0
11 years 5 days ago - 11 years 2 days ago #236035 by comyoo
Hi,

Thanks to this great component we can have user profiles and make lists of users who have the same value on the 'cb_team' field.

We migrated to joomla 3.1.5 from 2.5.14

We use this code with advanced filter in lists.
Code:
`cb_teams` REGEXP REPLACE( '[cb_teams]', ' ', '|' )

But when there is no value the 2.5.15 site gave a message 'you are not in a team'.
But now we get this error:
Code:
Fout: 0 SQL=SELECT COUNT(DISTINCT u.id) FROM nkb57_users u JOIN nkb57_user_usergroup_map g ON g.user_id = u.id JOIN nkb57_comprofiler ue ON ue.id = u.id WHERE u.block = 0 AND ue.approved = 1 AND ue.confirmed = 1 AND g.group_id IN (6, 7, 2, 3, 9, 4, 5, 14, 20, 18, 21, 19, 15, 13, 16, 17, 10, 11, 12, 8) AND (cb_teams REGEXP REPLACE( '', ' ', '|' ))

How can we edit the regex to get the right message or 'nice' message instead of an error.
Last edit: 11 years 2 days ago by krileon.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48478
  • Thanks: 8282
  • Karma: 1443
11 years 5 days ago - 11 years 5 days ago #236053 by krileon
Replied by krileon on topic Error is display list with regex
Joomla version doesn't matter. You can't have an empty REGEXP as it'll error MYSQL. You're probably better off using FIND_IN_SET and comma delimitering your field. I assume your field is a multi-select fieldtype in which case it's stored as |*| delimitered. So the below should work for your needs.

Code:
FIND_IN_SET( `cb_teams`, REPLACE( '[cb_teams]', '|*|', ',' ) ) != 0

The above usage is faster than REGEXP and won't error on empty values. REGEXP is very sensitive so I suggest only using it when you can absolutely guarantee the REGEX.


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: 11 years 5 days ago by krileon.

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

  • comyoo
  • comyoo
  • OFFLINE
  • Posts: 87
  • Thanks: 1
  • Karma: 0
11 years 4 days ago #236092 by comyoo
Replied by comyoo on topic Error is display list with regex
Hi krileon

The field is a text field With values like 150,176

Or by example: staf,150

Will your suggestion also work With comma seperated values in a text field?

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

  • comyoo
  • comyoo
  • OFFLINE
  • Posts: 87
  • Thanks: 1
  • Karma: 0
11 years 2 days ago #236192 by comyoo
Replied by comyoo on topic Error is display list with regex
Nice. It is working.

Thank you!
The following user(s) said Thank You: krileon

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

  • comyoo
  • comyoo
  • OFFLINE
  • Posts: 87
  • Thanks: 1
  • Karma: 0
10 years 8 months ago #241702 by comyoo
Replied by comyoo on topic Error is display list with regex
HI Krileon,

The reqex is not working when there are 2 values comma seperated in the cb_teams field.

How can we modify the regex to let it work?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48478
  • Thanks: 8282
  • Karma: 1443
10 years 8 months ago #241722 by krileon
Replied by krileon on topic Error is display list with regex
You can't do that with FIND_IN_SET. The first argument always has to be a string. It can not compare a comma separated list of strings against another comma separated list of strings. You'll probably need some sort of custom MYSQL function to handle your specific case as you can not have an empty REGEXP usage so using REGEXP won't be possible in your case unless you can guarantee some sort of value (maybe a substitution IF statement to force a value of some kind).


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