I am using a custom query as the Active Record equivelant did not work for me.
When开发者_开发百科 placing the Query in my Database Software SQLYOG it works fine however in CodeIgniter it says
A Database Error Occurred
Error Number: 1096
No tables used
SELECT *
Filename: C:\xampp\htdocs\midas\system\database\DB_driver.php
Line Number: 330
Here is my Query:
SELECT intervention.department_id, department_name, COUNT(*)
FROM intervention
LEFT JOIN department ON department.department_id = intervention.department_id
GROUP BY intervention.department_id, department.department_name
ORDER BY COUNT(*) desc
LIMIT 1
It is a bit of a strange problem.
Here is my Schema also:
http://i.imgur.com/mKNtc.png
Its ok I figured it out.
For custom query in Codeigniter you cannot use get method after.
EDIT
This will not work. As noted below only COUNT(*)
or COUNT(table.field)
work.
I think you need to specify which table you are using COUNT(*)
on, so change it to something like COUNT(department.*)
or COUNT(intervention.*)
If you use custom queries in Code Igniter you must return the result (Database object) to controller, because get method (from $this->db
) doesn´t work.
精彩评论