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
|
Messages In This Thread |
how to solve this db error? - by waptik - 04-14-2016, 01:36 PM
RE: how to solve this db error? - by jonathanq - 04-14-2016, 03:40 PM
RE: how to solve this db error? - by waptik - 04-15-2016, 09:50 AM
RE: how to solve this db error? - by SubjectX - 04-15-2016, 04:37 AM
|