Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 或者在codeigniter上的哪个组_Php_Mysql_Codeigniter - Fatal编程技术网

Php 或者在codeigniter上的哪个组

Php 或者在codeigniter上的哪个组,php,mysql,codeigniter,Php,Mysql,Codeigniter,我在codeigniter中有这样的代码 foreach ($where as $k=>$v){ foreach ($v as $val){ $this->db->or_where($k, $val); } } 但是,我想要的是“或者说是哪一组”之类的 select * from table where id = '1' and (category = 'tekno' OR category ='bio

我在codeigniter中有这样的代码

foreach ($where as $k=>$v){
    foreach ($v as $val){
        $this->db->or_where($k, $val);  
    }                   
}
但是,我想要的是“或者说是哪一组”之类的

select * from table where id = '1' and (category = 'tekno' OR category ='biologi');

有什么想法吗

如果需要更复杂的where子句分组,我经常求助于手动构建查询

$or_where = "";
foreach ($where as $k => $v) {
    foreach ($v as $val) {
        $or_where .= "OR category = '$val' ";
    }                   
}
然后,您可以将以下内容添加到现有活动记录查询中:

$this->db->where($or_where);


如果需要更复杂的where子句分组,我经常求助于手动构建查询

$or_where = "";
foreach ($where as $k => $v) {
    foreach ($v as $val) {
        $or_where .= "OR category = '$val' ";
    }                   
}
然后,您可以将以下内容添加到现有活动记录查询中:

$this->db->where($or_where);


您可以在以下位置添加更多内容:

$this->db->where('id', 1);
$this->db->where('(category', 'tekno');
$this->db->or_where('category', 'biologi');
$this->db->where('1=1)');

您可以在以下位置添加更多内容:

$this->db->where('id', 1);
$this->db->where('(category', 'tekno');
$this->db->or_where('category', 'biologi');
$this->db->where('1=1)');

你的代码到底给了你什么,相对于你想要它给你什么?你的代码到底给了你什么,相对于你想要它给你什么?