Not Equal to Comparison in Codeigniter Active records

久未见 提交于 2021-01-28 05:03:45

问题


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));

Here is what I get the Error

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:


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));


来源:https://stackoverflow.com/questions/15473965/not-equal-to-comparison-in-codeigniter-active-records

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!