[英]Codeigniter mysql query AND_OR
Just trying to write custom string for $this->db->where();
只是尝试为$this->db->where();
写自定义字符串$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']";
You're mixing two types of parameters for the $this->db->where()
function. 您正在为$this->db->where()
函数混合两种类型的参数。
From the docs http://ellislab.com/codeigniter/user-guide/database/active_record.html 从文档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'";
您可以提供一个关联数组(例如'phone' => $this->input->post('phone')
),或者提供一个自定义字符串$where = "name='Joe' AND status='boss' OR status='active'";
Joe'AND $where = "name='Joe' AND status='boss' OR status='active'";
boss'OR $where = "name='Joe' AND status='boss' OR status='active'";
You can't mix the two 你不能混合两者
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.