It looks like you're new here. If you want to get involved, click one of these buttons!
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Database_tools {
public function __construct()
{
}
public function is_not_existing_unique_field($value, $table, $column) {
$this->CI = &get_instance();
$this->CI->db->select($column);
$this->CI->db->from($table);
$this->CI->db->where($column, strtolower($value));
$this->CI->db->limit(1);
$query = $this->CI->db->get();
if($query->num_rows() == 0) {
return true;
}
return false;
}
}
$this->validator->add_rule('email', 'is_not_existing_unique_field', 'That e-mail address is already registered by someone else', array($_POST['email'], 'msa_students', 'student_email'));
Comments
$this->validator->add_rule('email', array($my_obj => 'is_not_existing_unique_field'), 'That e-mail address is already registered by someone else', array($_POST['email'], 'msa_students', 'student_email'));
The key is the instance of the object, and the value is the method to call. If the method exists on the current object, then you use "$this".
Also, it may not be relevant to how you have things setup, but there is a unique_fields property you can set on your model that will automatically check for unique values in the database upon save.
http://www.getfuelcms.com/user_guide/libraries/my_model