与Codeigniter活动记录中的比较不相等

时间:2013-03-18 09:59:11

标签: codeigniter activerecord

我对使用此代码

收到的此错误感到困惑
$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

1 个答案:

答案 0 :(得分:6)

尝试这样的查询。对Admin使用单个逗号而不是双逗号。并且<>而不是!=

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