tp5 关于条件的一些疑惑。

浏览:4836 发布日期:2016/12/29 分类:ThinkPHP5专区
<?php

namespace app\index\controller;
use think\Controller;
use think\Db;
use think\Cache;
use think\Url;
use think\Request;


/*
 * 控制器
 * Carey
 * 2016年12月29日22:05:41
 */
class Index extends Controller {

    //第一个方法
    public function index(){
        $list = Db::name('user')->where(array('name'=>array('<>','')))->paginate(10);

        $this->assign('list',$list);
        return view();
    }




}
上面的代码可以正常执行:<?php

namespace app\index\controller;
use think\Controller;
use think\Db;
use think\Cache;
use think\Url;
use think\Request;


/*
 * 控制器
 * Carey
 * 2016年12月29日22:05:41
 */
class Index extends Controller {

    //第一个方法
    public function index(){
        $list = Db::name('user')->where(array('name'=>array('neq','')))->paginate(10);

        $this->assign('list',$list);
        return view();
    }




}
无论是 NEQ 还是neq 都直接报错,找不到匹配的函数:[0] Exception in Builder.php line 198
查询表达式错误:neq

                return $str;
            }

            // 检测操作符
            if (!in_array($exp, $this->exp)) {
                $exp = strtolower($exp);
                if (isset($this->exp[$exp])) {
                    $exp = $this->exp[$exp];
                } else {
                    throw new Exception('where express error:' . $exp);
                }
            }

            $query = [];
            if ('=' == $exp) {
                // 普通查询
                $query[$key] = $this->parseValue($value, $key);
            } elseif (in_array($exp, ['neq', 'ne', 'gt', 'egt', 'gte', 'lt', 'lte', 'elt', 'mod'])) {
                // 比较运算
最佳答案
评论( 相关
后面还有条评论,点击查看>>