Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class My_Form_validation extends CI_Form_validation {
- function __construct($rules = array())
- {
- parent::__construct();
- $CI =& get_instance();
- $this->_config_rules = $rules;
- }
- // --------------------------------------------------------------------
- /**
- * Unique
- *
- * @access public
- * @param string
- * @param field
- * @return bool
- */
- function unique($str, $field)
- {
- $CI =& get_instance();
- list($table, $column) = explode('.', $field, 2);
- $CI->form_validation->set_message('unique', 'The %s that you requested is unavailable.');
- $query = $CI->db->query("SELECT COUNT(*) AS dupe FROM $table WHERE $column = '$str'");
- $row = $query->row();
- return ($row->dupe > 0) ? FALSE : TRUE;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement