Issue with or_where

Issue with or_where

axel_tsysaxel_tsys Posts: 12Questions: 4Answers: 0
edited June 7 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: 12,109Questions: 0Answers: 2,059

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

    Colin

  • axel_tsysaxel_tsys Posts: 12Questions: 4Answers: 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: 12,109Questions: 0Answers: 2,059

    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: 54,181Questions: 1Answers: 8,456 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: 12Questions: 4Answers: 0

    Hello,
    thanks that is the solution :-)

Sign In or Register to comment.