51 Posts
ostap
5 years ago
7
Topic

There Is A"List & Search Type". In " Search Form "there are many fields and after clicking the button the query is processed in the field of type"Query". Appeals to the value of the fields is made through the type design:

... WHERE id_region = " $uri - >getValue(reg_el)" …

Everything works fine! There was a need to include a field of type "CheckBox" to be able to select multiple values.

I did this, created a field with id= "level_election", entered the necessary parameters:

http://prntscr.com/mrpmyq

Got:

http://prntscr.com/mrpqci

Now there was a question how to process it in SQL query?

After you click the button in the URL bar, it looks like this (when you select Level 1 b Level 3):

"...level_election%5B%5D=1&level_election%5B%5D=3...»

In an SQL query, it should be something like:

... WHERE id_level in (……) …

I looked on the Internet, but it is written through the processing of PHP, and how to do it directly?

Get a VIP membership
1283 Posts
Bucklash
5 years ago
2
Level 1

1

Pulsar Informatique have seblod  plugins that might help with this

2

cant remember if you can do sonething like WHERE ‘x’ IN (\‘$cck->getValue(‘something’)\’)

3

maybe do a search join on relevant table somehow and then no need for the query, apply match and have set to grab value from url

51 Posts
ostap
5 years ago
1
Level 2

Thank you so much for trying to help, but 

"1. Pulsar Informatique have seblod plugins that might help with this"

- I do not know such plugins and have not found them 

"2. cant remember if you can do something like WHERE ‘x ' in (\'$cck->getValue ('something’)\')» 

- I already tried it, it didn't work. 

"3. maybe do a search join on relevant table something and then no need for the query, apple match and have set to grab value from url» 

- I don't understand.

1283 Posts
Bucklash
5 years ago
0
Level 3

sorry

i read question wrong....

is match 3 all good? 

215 Posts
iliil
5 years ago
0
Level 1

Hi 

The URL seems ok, please enable the debug mode to see the query ( SEBLOD > OPTIONS > SITE > DEBUG ). 

What is the Match value in your search form checkbox field? Try "any words exact" (separated by ",") and check the query again.

Best

Michal

51 Posts
ostap
5 years ago
1
Level 1

I spent a lot of time: nothing happened.

Decided in a roundabout way

So: we have a field of type check box( a dynamic check). As delimiters commas.

Task: Use the value of the field in in the SQL query "Search Query »


STEP # 1

I create a working field of type "text" ('w_result'). The total value of the checkbox field (dynamic check box) will be copied to this field . Indispensably:

1. Check box Enter the same default value here, in and as (check box dynamic).For example: "1,2,3,4»

2. #1-type " URL”

3. In the hidden Place 'w_result' (hidden) section of the template


STEP # 2

No. 5

The check box in the event of a change in prescribed working rules For the field 'w_result'

http://prntscr.com/mtciyt


STEP # 3

In the environment of SQL-query write (that's it!!! without quotes!!!):

SELECT * FROM TABLE

WHERE id_level IN ($URI->getValue('w_result'))

5 years ago
0
Level 2

Hi ostap,

Not sure to follow the complexity of what you're doing.

If you want to search multiple value of checkbox you need to change the "match" applied to your field by something like "any words" (see button 3 on Search Form).

To see the full SQL query, I invite you to enable the debug into the configuration tab.

Thanks.

4229 Posts
Kadministrator
5 years ago
0
Level 1

Hi,

if I understood your post correctly (it is a bit hard to follow due to translation) your basic problem here is that checkbox does not have a single string value, it has multiple values that are posted as an array of values - while what you need is a comma separated string. I would say you found the only way to make this work by yourself, you are converting an array to a string on the client side. Server side option would be to use some plugin that would run on event fired before values are processed, but don't know if any of the events available in Seblod fire early enough.

I must admit I did not know computation rules would work in this case, I would probably write custom javascript function for this :)

Get a Book for SEBLOD