Welcome Guest, Not a member yet? Register   Sign In
question: how to pass a variable from model to view
#5

[eluser]Zack Kitzmiller[/eluser]
You can store the error message in a session variable, but I would do that in the controller. It makes for more re-usable code.

In Model:
Code:
function get_name_exists($name){
    $query=$this->db->query("Select * from users where name='".$name."' ;");
        if($query->num_rows()>0){
            return true;
        }
     return false;
}

In Controller
Code:
function some_function() {

    if ($this->some_model->get_name_exists) {
        $this->session->set_userdata('error', 'Username exists');    
    }

}

However, I'd probably tackle this is a completely different way.


Messages In This Thread
question: how to pass a variable from model to view - by El Forum - 03-27-2010, 10:42 PM
question: how to pass a variable from model to view - by El Forum - 03-28-2010, 12:39 AM
question: how to pass a variable from model to view - by El Forum - 03-28-2010, 01:03 AM
question: how to pass a variable from model to view - by El Forum - 03-28-2010, 01:05 AM
question: how to pass a variable from model to view - by El Forum - 03-28-2010, 07:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB