Where multiselect filter on array

Where multiselect filter on array

CapamaniaCapamania Posts: 233Questions: 81Answers: 5
edited November 2016 in Editor

I have a multiselect filter which works great if a specifc id has only one value allocated.

account_mm:

id iso_01
1 DE
2 DE
3 FR
4 FR
5 US

But what if a specifc id has multiple values like:

account_mm

id iso_01
1 DE
2 DE
3 FR, DE
4 FR, DE, US
5 US

I tried this but no result:

$id->or_where( 'account_mm.iso_01', '%'.$_POST["selectID"].'%'[$i], 'LIKE'  );

I also tried ....

$id->or_where( 'account_mm.iso_01', $_POST["%selectID%"][$i], 'LIKE'  );

... which does some filtering but shows all the rows with a value in it.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,356Questions: 1Answers: 10,444 Site admin
    Answer ✓

    A combination of the first two:

    $id->or_where( 'account_mm.iso_01', '%'.$_POST["selectID"][$i].'%', 'LIKE'  );
    

    You want it to look like WHERE account_mm.iso_01 LIKE '%searchTerm%' eventually.

    Allan

  • CapamaniaCapamania Posts: 233Questions: 81Answers: 5

    Perfect ... this works for me. Many thanks

This discussion has been closed.