How to make OR statement with this :

How to make OR statement with this :

stancaballerostancaballero Posts: 29Questions: 9Answers: 0

->select( 'tbl_branchpersonel_master', ['tbl_branchpersonel_master.employee as value', 'tbl_branchpersonel_master.employee as label'], ['tbl_branchpersonel_master.regionname' => $_REQUEST['values']['tbl_branch_incentives_master.regionname'], 'tbl_branchpersonel_master.branchname' => $_REQUEST['values']['tbl_branch_incentives_master.branchname']], ['label ASC'] )
->fetchAll();

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,482Questions: 1Answers: 10,467 Site admin
    Answer ✓

    The select() method doesn't let you build an OR condition query. What you need to do is use the Query class long hand. The select() method is basically:

            return $this->query( 'select' )
                ->table( $table )
                ->get( $field )
                ->where( $where )
                ->order( $orderBy )
                ->exec();
    

    So you'd so something similar:

    $query = $db->query('select')
      ->table( ... )
      ->get( ... )
      ->where( ... )
      ->or_where( ... )
      ->order( ... )
      ->exec();
    
    $results = $query->fetchAll();
    

    Allan

  • stancaballerostancaballero Posts: 29Questions: 9Answers: 0

    Thank you sir

Sign In or Register to comment.