Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function react_post($post_id, $reaction_name) {
- if ($this->session->userdata('teacher_login') != 1 || $this->session->userdata('teacher_type') != 1)
- redirect(base_url(), 'refresh');
- $check = $this->db->get_where('reactions', array(
- 'post_id' => $post_id,
- 'user_id' => $this->session->userdata('teacher_id'),
- 'user_type' => 'teacher',
- ))->row();
- $data['reaction_name'] = $reaction_name;
- if(empty($check)) {
- $data['post_id'] = $post_id;
- $data['user_type'] = 'teacher';
- $data['user_id'] = $this->session->userdata('teacher_id');
- $this->db->insert('reactions', $data);
- } else {
- $this->db->where('id', $check->id);
- $this->db->update('reactions', $data);
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement