jdlau 发表于 2015-3-4 09:59:02

$this->db->get('t_account')

我在用CI操作数据库时报以下错误,有人知道怎么解决吗?
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 'FROM (`t_account`) WHERE `userId` = '10001' GROUP BY `type`' at line 2

SELECT date_format(createTime, `'%x')` as year, date_format(createTime, `'%v')` as week, SUM(`money`) AS money FROM (`t_account`) WHERE `userId` = '10001' GROUP BY `type`

Filename: /data/home/jd/Project/JdManager/server/models/maccount/account_model.php

Line Number: 136

Closer 发表于 2015-3-4 10:07:35

請貼上第 136 行那個區塊的方法全代碼
並附註你注入的參數為何

baiyuxiong 发表于 2015-3-4 13:03:04

使用了group by以后,createTime就不能用了吧?只能使用group by 里的字段和聚类函数,比如sum求和,avg求平均值,count求计数这些。

57sy.com(隐身中 发表于 2015-3-6 17:33:26

:lol:lol:lol:lol:lol
页: [1]
查看完整版本: $this->db->get('t_account')