+ -
当前位置:首页 → 问答吧 → where条件问题,急!!!

where条件问题,急!!!

时间:2011-05-14

来源:互联网

想做一个城市三级联动的下拉列表功能
在ACTION中,写了如下的方法:
public function provinces(){
        $area = D("Area");
        $district = $area->where('substr(a_id,2,4)="0000"')->select();
        if($district){
            $this->ajaxReturn($district,"省份取值成功",1);
        }else{
            $this->ajaxReturn($district,"省份取值失败",0);
        }
    }
目的:想获得a_id字段中,后4位为“0000”的记录。
问题:上述代码,只返回一条“重庆”的记录,这是为什么? 应该怎么写才是正确的?

作者: comeon2122   发布时间: 2011-05-14

数据库支持substr 函数吗?
你是否应该写成 where(a_id like '%0000') 这种的

作者: huisebeizi   发布时间: 2011-05-19