Welcome Guest, Not a member yet? Register   Sign In
ActiveRecord for CodeIgniter: Rails-style model interactions
#94

[eluser]beemr[/eluser]
Here, to save you a click, this is what I wrote.

To integrate a “unique” validation into models based on the Activerecord_Class_Mod library, simply tie in the object features and put your standard callback functions into application/libraries/Activerecord.php:
Code:
function is_unique($value, $field)
    {
    $this->validation->set_message($this->_class_name.'->is_unique','The %s "'.$value.'" is not available. Try a different %s.');
    $this->db->where($field,$value);
    $this->db->from($this->_table);
    return ($this->db->count_all_results() == 0);
    }


Messages In This Thread
ActiveRecord for CodeIgniter: Rails-style model interactions - by El Forum - 03-26-2008, 12:17 PM



Theme © iAndrew 2016 - Forum software by © MyBB