Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2015
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. <?php
  2. /** application/libraries/MY_Form_validation **/
  3. class MY_Form_validation extends CI_Form_validation
  4. {
  5. public $CI;
  6. public $_field_data = array();
  7. public $_config_rules = array();
  8. public $_error_array = array();
  9. public $_error_messages = array();
  10. public $_error_prefix = '<p>';
  11. public $_error_suffix = '</p>';
  12. public $error_string = '';
  13. public $_safe_form_data = FALSE;
  14.  
  15. /**
  16. * Is Unique
  17. *
  18. * Check if the input value doesn't already exist
  19. * in the specified database field.
  20. *
  21. * @param string
  22. * @param string field
  23. * @return bool
  24. */
  25. public function is_unique($str, $field)
  26. {
  27. sscanf($field, '%[^.].%[^.]', $table, $field);
  28. if ($this->CI->db !== NULL)
  29. {
  30. $query = $this->CI->db->limit(1)->get_where($table, array($field => $str));
  31. return $query->num_rows() === 0;
  32. }
  33. return FALSE;
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement