Php 拆下'';前后()

Php 拆下'';前后(),php,mysql,sql-server,database,codeigniter,Php,Mysql,Sql Server,Database,Codeigniter,从下面的代码中,我得到一个sql查询: SELECT * FROM `tblstaff` WHERE `active` = 1 AND role IN '(10,7,4,5)' AND staffid IN '(3,8,9,12,2 )' AND `is_not_staff` =0 ORDER BY `firstname` DESC 使用使查询出错的“()”n,值来自$staffids和$roleid,这是一个字符串,因此当转换为关联数组时,它将以”(10,2,5)的形式给出输出。因此,如何从

从下面的代码中,我得到一个sql查询:

SELECT * FROM `tblstaff` WHERE `active` = 1 AND role IN '(10,7,4,5)'
AND staffid IN '(3,8,9,12,2 )' AND `is_not_staff` =0 ORDER BY
`firstname` DESC
使用使查询出错的“()”n,值来自$staffids和$roleid,这是一个字符串,因此当转换为关联数组时,它将以”(10,2,5)的形式给出输出。因此,如何从查询中删除'

SELECT * FROM `tblstaff` WHERE `active` = 1 AND role IN '(10,7,4,5)'
AND staffid IN '(3,8,9,12,2 )' AND `is_not_staff` =0 ORDER BY
`firstname` DESC
      if ($staff_role != STAFF_ROLE_SALE_AGENT_FTD_ID && $staff_role != STAFF_ROLE_SALE_AGENT_RETENTION_ID && ($view_own || $view )){
            if(get_staff_role() == STAFF_ROLE_ADMIN_ID){  
                $where['role NOT IN '] = "( ". STAFF_ROLE_SA_ID ." )" ; 
            } else{
                    $roleids = get_immediate_roleids();
                    if($roleids != ''){
                        $where['role IN'] = '('. $roleids .')';                
                    }
                }
            if($staff_role != STAFF_ROLE_SA_ID){
                if($view_own){
                    $staffids = get_immediate_staffids($staff_id); echo $staffids;
                    $where['staffid IN'] =  $staffids ." )" ;
                } else if(is_numeric($staff_office_id) && $staff_office_id > 0){
                        $staffids = get_immediate_staffids_under_office('', $staff_office_id);echo $staffids;
                        $where['staffid IN'] = "(". $staffids  ." )" ;
                    }
            }

如果使用CI查询生成器,则必须更改方法:

SELECT * FROM `tblstaff` WHERE `active` = 1 AND role IN '(10,7,4,5)'
AND staffid IN '(3,8,9,12,2 )' AND `is_not_staff` =0 ORDER BY
`firstname` DESC
替换此:
$where['role NOT IN']=”(“.STAFF\u role\u SA\u ID.”)
与:
$this->db->where\u not\u in('role',STAFF\u role\u SA\u ID)
与Where In子句相同:

$this->db->where_in('staffid',$staffids)

您是否正在使用活动CI查询生成器?您可以向我显示查询生成器代码吗?$where['is\u not\u staff']=0$数据['members']=$this->staff_model->get('',1,$where)$数据['members']=$this->staff_model->get('',1,$where);在$data['members']中,如果您使用$this->db->where,则它存储在模型中,然后像这样使用$this->db->where($where,null,FALSE);
SELECT * FROM `tblstaff` WHERE `active` = 1 AND role IN '(10,7,4,5)'
AND staffid IN '(3,8,9,12,2 )' AND `is_not_staff` =0 ORDER BY
`firstname` DESC