NiceTry
NiceTry

Reputation: 360

Codeigniter mysql query AND_OR

Just trying to write custom string for $this->db->where(); function but I get syntax errors. Could you have a look on the code below to find the mistake

$where = "'phone' => $this->input->post('phone') AND '2g' = $data['2g'] OR '3g' = $data['3g'] OR '4g' = $data['4g']";

Upvotes: 0

Views: 40

Answers (1)

Patrick
Patrick

Reputation: 3367

You're mixing two types of parameters for the $this->db->where() function.

From the docs http://ellislab.com/codeigniter/user-guide/database/active_record.html

You either supply an associative array (like 'phone' => $this->input->post('phone')) or you suppliy a custom string $where = "name='Joe' AND status='boss' OR status='active'";

You can't mix the two

Upvotes: 1

Related Questions