Reputation: 997
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:
https://i.sstatic.net/WstcX.png
Upvotes: 1
Views: 27182
Reputation: 11
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.
Upvotes: 0
Reputation: 997
Its ok I figured it out.
For custom query in Codeigniter you cannot use get method after.
Upvotes: 7
Reputation: 61512
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.*)
Upvotes: 2