2

I'm new to codeigniter. I having a problem checking two values in field using a model with codeigniter.

I'm trying to check if "status" value is "Available" or "Notavailable"

I'm using this model to check but only one value. 'Available' Only.

public function withdraw_check($data)
{
    $this->db->select('game');
    $where = array('id_user' => $this->session->userdata('user_id'),
                   'status' => 'Available', 
                   'game' => $data,
                   'site' => $this->system_library->sitename()
                  );
    $this->db->where($where);
}

2 Answers 2

2

Why not use a WHERE IN statement:

$this->db->where_in('status',array('Available','Notavailable'));

SQL Produced:

WHERE status IN ('Available', 'Notavailable')

Final Code:

$this->db->select('game');
$this->db->where('id_user',$this->session->userdata('user_id'));
$this->db->where_in('status',array('Available','Notavailable'));
$this->db->where('game',$data);
$this->db->where('site', $this->system_library->sitename());
Sign up to request clarification or add additional context in comments.

1 Comment

I'll try that @Jeemusu tnx
0

Try like this,

 $this->db->select('game');
 $where = array
                (
                    'id_user' => $this->session->userdata('user_u_id'),
                    'game' => $data,
                    'site' => $this->system_library->sitename()
                );
$this->db->where('status=' ,'Pending');
$this->db->or_where('status=' ,'Hold');
$this->db->where($where);

1 Comment

` ''Pending' ` something wrong here. Double quotes coming there. Verify it again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.