Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function get_latest_pheeds() {
- $this->load->helper('date');
- $time = time();
- $q = $this->db->select("user_id,pheed_id,pheed,datetime,COUNT(pheed_comments.comment_id) as comments")
- ->from('pheeds')
- ->join('pheed_comments','pheed_comments.P_id=pheeds.pheed_id','left')
- ->group_by('pheed_id')
- ->order_by('datetime','desc')
- ->limit(30);
- $rows = $q->get();
- foreach($rows->result_array() as $row) {
- $data['user_id'] = $row['user_id'];
- $data['pheed_id'] = $row['pheed_id'];
- $data['pheed'] = $row['pheed'];
- $data['comments'] = $row['comments'];
- $data['datetime'] = timespan($row['datetime'],$time);
- }
- return $data;
- }
- function latest_pheeds() {
- if($this->isLogged() == true) {
- $this->load->model('pheed_model');
- $data = $this->pheed_model->get_latest_pheeds();
- echo json_encode($data);
- return false;
- }
- }
- $data[] = array(
- 'user_id' = $row['user_id'];
- 'pheed_id' = $row['pheed_id'];
- 'pheed' = $row['pheed'];
- 'comments' = $row['comments'];
- 'datetime' = timespan($row['datetime'],$time);
- ) ;
Add Comment
Please, Sign In to add comment