关于方法传参的问题

luckylover 9天前 69

`
public function index($dqzt = '')

{   
    $this->relationSearch = true;
    $this->searchFields = "department.dwmc,xm,jgh";//快速搜索

    $this->request->filter(['strip_tags']);
    $dqztm = [];
    switch($dqzt)
    {
        case 'zz':
        $dqztm = array('04','11');
        break;
        case 'lz':
        $dqztm = array('03','05','06','07','08','09');
        break;
        case 'tx':
        $dqztm = array('01','02');
        break;
        default;
        $dqztm = array('01','02','03','04','05','06','07','08','09','11');
        break;
    }

    //var_dump($dqztm);        
    //$dqztm = array('01','02');
    if ($this->request->isAjax())
    {
        list($where, $sort, $order, $offset, $limit) = $this->buildparams();
        $total = $this->model
        ->with("department")
        ->where($where)
        ->where('jzgdqzt','in',$dqztm)
        ->order($sort, $order)
        ->count();
        $list = $this->model
        ->with("department")
        ->where($where)
        ->where('jzgdqzt','in',$dqztm)
        ->order($sort, $order)
        ->limit($offset, $limit)
        ->select();
        $result = array("total" => $total, "rows" => $list);
        return json($result);
    }
    return $this->view->fetch();
}

`
$dqztm通过传参判断语句,VAR_DUMP出来的$dqztm是正常的,但是$list获取到的一直是default对应的数据? 如果直接指定$dqztm = array('01','02')又是正常。
访问的地址:http://www.f.cn/public/admin.php/rsgl/staff/index/dqzt/tx

最后于 9天前 被luckylover编辑
最新回复 (3)
  • myIvan 9天前
    感谢TA
    0 引用 2

    image.png

    你这里打印出来正确吗?是array('01','02')?

  • luckylover 楼主 9天前
    感谢TA
    0 引用 3
    myIvan ![image.png](//cdn.forum.fastadmin.net/uploads/201812/06/8b443b5d17d717392805c4aa4ba00268) 你这里打印出 ...

    var_dump打印出来时是array('01','02'),真的好奇怪嗄

  • myIvan 9天前
    感谢TA
    0 引用 4

    @luckylover 那就不懂了,撞鬼了

  • 未登录
    5
返回