|
本帖最后由 snllll 于 2011-2-13 00:03 编辑
升级后出现如下问题:
1、原来在model中操作时,无所谓多一个还是少一个from,我也就一直没注意过,现在发现不行了。
比如:
PHP复制代码
$this->db->select('title,createdate,id');
$this->db->from('news');
$query = $this->db->get('news',10);
复制代码
以前这样写是没问题的,但是现在会报错。必须将$this->db->from('news');这一句去掉。
2、where语句大面积出现问题。
我以前又少部分是sql语法,如手册中提到的:
PHP复制代码
[font=Verdana]$where = "name='Joe' AND status='boss' OR status='active'";
$this->db->where($where);[/font]
[font=Verdana] 复制代码
我写的是:
PHP复制代码
[font=Verdana]$sql = " cid>0"; [/font]
[font=Verdana]$this->db->where($where);[/font]
[font=Verdana] 复制代码
报错:
HTML复制代码 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 '0 ORDER BY `id` desc LIMIT 15' at line 3
SELECT * FROM (`news`) WHERE `cid>` 0 ORDER BY `id` desc LIMIT 15
Filename: XXXXXX\system\database\DB_driver.php
Line Number: 330
复制代码
我尝试了多种方法改写,均失败。
尝试过的方法:
PHP复制代码
[font=Verdana]$this->db->where('cid>',0);[/font]
[font=Verdana] 复制代码
同样的错误
接着来,以下这两句的效果一样的:
PHP复制代码
[font =Verdana ]$this->db->where('cid','>0');[/font ]
[font =Verdana ]$this->db->where(array('cid'=>'>0'));[/font ]
[font =Verdana ] 复制代码
加了一句echo $this->db->last_query(); 得到:
SQL复制代码
SELECT * FROM (`news`) WHERE `cid` = '>0' ORDER BY `id` DESC LIMIT 15
复制代码
PHP复制代码 $this->db->where(array('cid>'=>0)); 复制代码HTML复制代码 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 '0 ORDER BY `id` desc LIMIT 15' at line 3
SELECT * FROM (`news`) WHERE `cid>` 0 ORDER BY `id` desc LIMIT 15
Filename: ***\system\database\DB_driver.php
Line Number: 330
复制代码 |
|