原因就是筛选函数在处理数字的时候都统一使用了intval函数,那么这样一来intval(0.1) = 0,inval(0_10) = 0,这样都会被判断成0而造成各种问题。修复方法如下
(1)修改structure_filters_sql函数,改成:
代码中加粗甲红的表示修改过的代码
- function structure_filters_sql($modelid) {
- $sql = $fieldname = $min = $max = '';
- $fieldvalue = array();
- $modelid = intval($modelid);
- $model = getcache('model','commons');
- $fields = getcache('model_field_'.$modelid,'model');
- $fields_key = array_keys($fields);
- //TODO
- $sql = '`status` = '99'';
- foreach ($_GET as $k=>$r) {
- if(in_array($k,$fields_key) && floatval($r)!=0 && ($fields[$k]['filtertype'] || $fields[$k]['rangetype'])) {
- if($fields[$k]['formtype'] == 'linkage') {
- $datas = getcache($fields[$k]['linkageid'],'linkage');
- $infos = $datas['data'];
- if($infos[$r]['arrchildid']) {
- $sql .= ' AND `'.$k.'` in('.$infos[$r]['arrchildid'].')';
- }
- } elseif ($fields[$k]['formtype'] == 'box') {
- $sql .=" AND find_in_set($r,$k)";
- }
- //elseif($fields[$k]['boxtype']=='checkbox' || $fields[$k]['boxtype']=='multiple') {
- // $sql .= " AND `$k` LIKE '%,$r,%'";
- //}
- elseif($fields[$k]['rangetype']) {
- if(is_numeric($r)) {
- $sql .=" AND `$k` = '$r'";
- } else {
- $fieldvalue = explode('_',$r);
- $min = floatval($fieldvalue[0]);
- $max = $fieldvalue[1] ? floatval($fieldvalue[1]) : 999999;
- $sql .=" AND `$k` >= '$min' AND `$k` < '$max'";
- }
- } else {
- $sql .=" AND `$k` = '$r'";
- }
- }
- }
- return $sql;
- }
(2)修改不支持0开头的数字筛选
上面代码第11行的代码有个 floatval($r)!=0官方默认的是intval($r)!=0,这两天都硕说明了如果范围是0_100 这种都会被转化成0 而不满足筛选条件,所以只需要去掉这个判断即可,改成:
- if(in_array($k,$fields_key) && ($fields[$k]['filtertype'] || $fields[$k]['rangetype'])) {