Issue with or_where

Issue with or_where

axel_tsysaxel_tsys Posts: 19Questions: 5Answers: 0
edited June 2021 in Editor

Hi,
I try to create a web site from a Postgresql view table.
The php request includes a or_where command in relation to a user.

        ->where( function ($q) use ($iansites) {
                foreach($iansites as $tmp){
                        $q->or_where('view_union_current_adminlan_ruleset.ian_site', $tmp );
                }
        } )
       ->debug(true)
        ->process( $_POST )
        ->json();

$iansites is an array with about 40 values.

The web site will be shown correct but the search will not work.
It makes no differences which search possibilities I use.
It looks like the search will be performed because I got a new line at the bottom about the overall number of datassets but the number will also counts all datasets.

If the $iansites array only includes one value then the search is working correct.

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    Can you post the Ajax response please, with the debug present,

    Colin

  • axel_tsysaxel_tsys Posts: 19Questions: 5Answers: 0

    Hi Colin,
    Can I forward the answer direkt to you?
    I dont want to send the answer to a public chat and it looks like it is to long for the forum.

    Thanks

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    Sure - if you could post the JSON and the table definition, then one of us will take a look. Send direct to me and I may add others into the conversation,

    Colin

  • allanallan Posts: 61,438Questions: 1Answers: 10,052 Site admin
    Answer ✓

    I suspect you'll need to use:

    ->where( function ($q) use ($iansites) {
      $q->where(function ($r) use ($iansites) {
             foreach($iansites as $tmp){
                     $r->or_where('view_union_current_adminlan_ruleset.ian_site', $tmp );
             }
      });
     } )
    ->debug(true)
    ->process( $_POST )
    ->json();
    

    If that doesn't work, can you show me the JSON response from the server when you load your page?

    Allan

  • axel_tsysaxel_tsys Posts: 19Questions: 5Answers: 0

    Hello,
    thanks that is the solution :-)

Sign In or Register to comment.