在Codeigniter活动记录中不等于比较 [英] Not Equal to Comparison in Codeigniter Active records

查看:47
本文介绍了在Codeigniter活动记录中不等于比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对使用此代码收到的错误很困惑

I am quite confused with this error which i am receiving with this code

$this->db->order_by('uid','DESC')->where('type!=',"Admin")->get('user_profile',$config['per_page'], $this->uri->segment(3));

这是我得到的错误

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL      server version for the right syntax to use near ''Admin' ORDER BY `uid` DESC LIMIT 10' at line 3

SELECT * FROM (`user_profile`) WHERE `type!=` 'Admin' ORDER BY `uid` DESC LIMIT 10

Filename: C:\wamp\www\proposal\system\database\DB_driver.php

Line Number: 330

推荐答案

尝试这样的查询.对于Admin使用单个逗号,而不是两个逗号.和<>代替!=

Try your query like this. Use single commas for Admin instead of double commas. And <> instead of !=

$this->db
    ->where('type <>','Admin')
    ->order_by('uid','DESC')
    ->get('user_profile',$config['per_page'], $this->uri->segment(3));

这篇关于在Codeigniter活动记录中不等于比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆