Welcome Guest, Not a member yet? Register   Sign In
SQL Query dont work in CI
#1

[eluser]codeDeveloper[/eluser]
Hello,
Please, help me, why don't work this SQL query:
Code:
$this->db->query ('SELECT u.nick, f.fuin, count(o.time) as online FROM `icqdate_friends` as f JOIN `icqdate_users` as u ON u.uin=f.fuin LEFT JOIN `icqdate_online` as o ON f.fuin=o.uin and o.time > NOW() - INTERVAL 5 MINUTE WHERE f.uin=? group by f.fuin order by online', array(723640));
$q = $this->db->get();
return $q->result();

CodeIgniter writing:
Quote:A Database Error Occurred

Error Number: 1096

No tables used

SELECT *

P.S. If helping to rewrite the query to Active Record would be very grateful
#2

[eluser]pistolPete[/eluser]
If you use query(), you must not use get() as well!
Have a look at the userguide: http://ellislab.com/codeigniter/user-gui...eries.html
#3

[eluser]obiron2[/eluser]
also, you need to group by u.nick and f.fuin if you are going to select both.
#4

[eluser]codeDeveloper[/eluser]
Thank you, works.
And as to put into Active Record?
Suggest me?




Theme © iAndrew 2016 - Forum software by © MyBB