CodeIgniter Forums
check if the user already have this value - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: check if the user already have this value (/showthread.php?tid=69965)



check if the user already have this value - tokyoatom - 02-03-2018

I have a function called send resources, so basically the admin can send a resources to a specific user and i have new table called entries which I have the FK of user_id from tables users and res_id from resource_id.

my question is how can I check if the user already have that value from res_id. I need to have a somewhat a validation thingy. I cant figure it out. can you guys help me?

this is my controller 

public function ressend() {
$db = new resource_model();

$data = array(
   'user_id' => $this->input->post('resource_send_ID'),
   'res_id' =>  $this->input->post('resource_id'),    
);

$db->insertsendResources($data); 
redirect('curator_resource');
}

this is my model

public function insertsendResources($data) {

$this->db->insert('entries', $data);

}


RE: check if the user already have this value - InsiteFX - 02-03-2018

You would need to get the record by the users id and check the res_id and resource_id to see if they match