db->select('u.first_name, u.last_name, s.id, s.subscriptionId, s.authorisationId, s.transactionReference, s.amount, s.expirationDate, s.transactionDateTime, s.payment_mode, s.status'); $this->db->join('user_subscription s', 'u.user_id = s.user_id', 'left'); $this->db->where('u.user_id', $user_id); $this->db->order_by('s.date_created','DESC'); return $this->db->get('user u')->row(); } /** * Update subscription by user id */ public function update_subscription($id, $data) { foreach ($data as $key => $value) { $this->db->set($key, $value); } $this->db->where('id', $id); return $this->db->update('user_subscription'); } public function update_user($id, $data) { foreach ($data as $key => $value) { $this->db->set($key, $value); } $this->db->where('user_id', $id); return $this->db->update('user'); } public function update_subscriber($id, $data) { foreach ($data as $key => $value) { $this->db->set($key, $value); } $this->db->where('subscriber_id', $id); return $this->db->update('user_subscriber'); } }