Guest User

Untitled

a guest
Jul 20th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. function get_latest_pheeds() {
  2. $this->load->helper('date');
  3. $time = time();
  4. $q = $this->db->select("user_id,pheed_id,pheed,datetime,COUNT(pheed_comments.comment_id) as comments")
  5. ->from('pheeds')
  6. ->join('pheed_comments','pheed_comments.P_id=pheeds.pheed_id','left')
  7. ->group_by('pheed_id')
  8. ->order_by('datetime','desc')
  9. ->limit(30);
  10. $rows = $q->get();
  11. foreach($rows->result_array() as $row) {
  12. $data['user_id'] = $row['user_id'];
  13. $data['pheed_id'] = $row['pheed_id'];
  14. $data['pheed'] = $row['pheed'];
  15. $data['comments'] = $row['comments'];
  16. $data['datetime'] = timespan($row['datetime'],$time);
  17. }
  18. return $data;
  19. }
  20.  
  21. function latest_pheeds() {
  22. if($this->isLogged() == true) {
  23. $this->load->model('pheed_model');
  24. $data = $this->pheed_model->get_latest_pheeds();
  25.  
  26. echo json_encode($data);
  27.  
  28. return false;
  29. }
  30. }
  31.  
  32. $data[] = array(
  33. 'user_id' = $row['user_id'];
  34. 'pheed_id' = $row['pheed_id'];
  35. 'pheed' = $row['pheed'];
  36. 'comments' = $row['comments'];
  37. 'datetime' = timespan($row['datetime'],$time);
  38. ) ;
Add Comment
Please, Sign In to add comment