Advertisement
Guest User

Untitled

a guest
May 27th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. function react_post($post_id, $reaction_name) {
  2.         if ($this->session->userdata('teacher_login') != 1 || $this->session->userdata('teacher_type') != 1)
  3.           redirect(base_url(), 'refresh');
  4.    
  5.         $check = $this->db->get_where('reactions', array(
  6.           'post_id'   => $post_id,
  7.           'user_id'   => $this->session->userdata('teacher_id'),
  8.           'user_type' => 'teacher',
  9.         ))->row();
  10.    
  11.         $data['reaction_name'] = $reaction_name;
  12.    
  13.         if(empty($check)) {
  14.           $data['post_id']       = $post_id;
  15.           $data['user_type']     = 'teacher';
  16.           $data['user_id']       = $this->session->userdata('teacher_id');
  17.    
  18.           $this->db->insert('reactions', $data);
  19.         } else {
  20.           $this->db->where('id', $check->id);
  21.           $this->db->update('reactions', $data);
  22.         }
  23.    
  24.         return true;
  25.       }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement