用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1457|回复: 4
收起左侧

一个关于where()的问题

[复制链接]
发表于 2012-12-15 13:17:21 | 显示全部楼层 |阅读模式
PHP复制代码
        public function test()
        {
                $res = $this->db->select('id')->where('id!=', 1)->get('char')->row_array();
                var_dump($this->db->last_query());exit;
        }
复制代码


显示错误:
                A Database Error Occurred                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 '1' at line 3
SELECT `id`FROM (`char`)WHERE `id!=` 1
Filename: D:\Web\wamp\www\maimoe\system\database\DB_driver.php
Line Number: 330


之前用where('id!=', 1)这种写法未出现过错误,手册中也说明可以这样编写,可是今天突然出现这个问题。

发表于 2012-12-15 13:56:44 | 显示全部楼层
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 '1' at line 3
看下自己数据库版本。
发表于 2012-12-15 14:29:37 | 显示全部楼层
id和!=间留个空格吧。ci给你换成一个字段了。
 楼主| 发表于 2012-12-15 14:35:35 | 显示全部楼层
seedo 发表于 2012-12-15 14:29
id和!=间留个空格吧。ci给你换成一个字段了。

次奥 范2了
发表于 2012-12-15 15:06:07 | 显示全部楼层
stellahime 发表于 2012-12-15 14:35
次奥 范2了

这个不范2哦, 这个也算CI的一个特色吧

本版积分规则