how to solve this db error? |
I am trying to list statistics about my contents.
I have these tables{(sms:id,status,like,user,sms); (like_today:id,sms_id,vote,date); (like_history:id,sms_id,vote,date) } This is my php code: $this->db->select("*")->from("sms"); $this->db->where('sms.status', 'A'); if($day=='today'){ $this->db->select("COUNT('like_today.sms_id') as vote"); $this->db->join('id', 'sms.id = like_today.sms_id', 'LEFT'); $this->db->group_by('like_today.sms_id'); }else{ $this->db->select("COUNT('like_history.vote') as vote"); if($day=='yesterday') $this->db->where('like_history.date', date('Ymd',strtotime('-1 day'))); if($day=='week') $this->db->where('like_history.date >', date('Ymd',strtotime('-1 week'))); if($day=='month') $this->db->where('like_history.date >', date('Ymd',strtotime('-1 month'))); $this->db->join('id', 'sms.id = like_history.sms_id', 'LEFT'); $this->db->group_by('like_history.sms_id'); } $this->db->order_by('vote', "DESC"); $c = $this->db->get(); and this the error i get : A Database Error Occurred Error Number: 1142 SELECT command denied to user 'db_name'@localhost for table 'id' SELECT *, COUNT('like_today.sms_id') as vote FROM `sms` LEFT JOIN `sms`.`id` ON `sms`.`id` = `like_today`.`id` WHERE `sms`.`status` = 'A' GROUP BY `like_today`.`sms_id` ORDER BY `vote` DESC . Any help?
Be Simple
(04-14-2016, 01:36 PM)waptik Wrote: I am trying to list statistics about my contents. this=> $this->db->join('id', replace and put => $this->db->join('like_today', (04-14-2016, 03:40 PM)jonathanq Wrote:(04-14-2016, 01:36 PM)waptik Wrote: I am trying to list statistics about my contents. Thanks man,it works!
Be Simple
|
Welcome Guest, Not a member yet? Register Sign In |