Advertisement
freddy0512

check-field-exist

Aug 10th, 2015
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. <!------begin controller--->
  2.  
  3. $this->form_validation->set_rules('sli_status', 'Status', 'trim|required|callback_isExist');
  4. $this->form_validation->set_error_delimiters('<font color="red">', '</font>');
  5.  
  6. if ($this->form_validation->run() == FALSE)
  7. {
  8.  
  9. }
  10. else {
  11. //do insert database
  12. }
  13.  
  14. public function isExist() {
  15. $is_exist = $this->model_slide->isExist();
  16. if ($is_exist) {
  17. $this->form_validation->set_message(
  18. 'isEmailExist', 'Status dengan classa ctive sudah ada'
  19. );
  20. return false;
  21. } else {
  22. return true;
  23. }
  24. }
  25.  
  26.  
  27.  
  28.  
  29. <!----------------------model ------------------------->
  30. function isExist() {
  31. $this->db->where('sli_status','active');
  32. $this->db->select("*");
  33. $this->db->from("slide");
  34. $query=$this->db->get();
  35. if ($query->num_rows() > 0) {
  36. return true;
  37. } else {
  38. return false;
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement