prince kumar
prince kumar

Reputation: 41

codeigniter get where with two same values

we want search data from sales table where , payment_status is pending . i try -

$this->datatables
        ->select("id, date, reference_no, biller, customer, sale_status")
        ->from('sales')
        ->where('due_date <=', date('Y-m-d'))
        ->where('payment_status =', 'pending')

it work good , but when we want search both value of payment_status , pending & partial at same time it not work. i try this code-

$this->datatables
        ->select("id, date, reference_no, biller, customer, sale_status, grand_total, paid, (grand_total-paid) as balance, payment_status")
        ->from('sales')
        ->where('due_date <=', date('Y-m-d'))
        ->where('payment_status =', 'pending')
        ->where('payment_status =', 'partial');

Upvotes: 2

Views: 43

Answers (1)

Saty
Saty

Reputation: 22532

Use or_where

$this->datatables
        ->select("id, date, reference_no, biller, customer, sale_status, grand_total, paid, (grand_total-paid) as balance, payment_status")
        ->from('sales')
        ->where('due_date <=', date('Y-m-d'))
        ->where('payment_status =', 'pending')
        ->or_where('payment_status =', 'partial');

It make you condition where (payment_status ='pending' OR payment_status ='partial' )

Upvotes: 2

Related Questions