Welcome Guest, Not a member yet? Register   Sign In
Need help with controller and accessing object
#1

(This post was last modified: 04-02-2015, 11:23 AM by ciadmin.)

[eluser]Robert M.[/eluser]
Hi @ all together.

This will be my first time here in the CI Forum. A have a small problem with understading how i can access an result in controller.

I got an error message like \"Trying to get property of non-object\" on line...

I want to do some like this.


Code:
function get_something($some_var){

    $this->load->model(\'some_model\',\'\',TRUE);
    $data[\'query\'] = $this->some_model->get_some_thing($some_var);
    
    if($data[\'query\']->col2==some_value){    //<--this will be the line where i get the error.
        $this->load->view(\'view_1\',$data);
    }else{
        $this->load->view(\'view_2\',$data);
    }
    

}

i know my mistake but i don\'t understand how i can access the value. normally in the view i do some like this

Code:
foreach($query as $row):
echo \"col2: \".$row->col2;

and so on but i want access the vaule in the controller

the function in some_model looks like this...

Code:
function get_some_thing($some_var){

    $this->db->select(\'col1\');
    $this->db->select(\'col2\');
    $this->db->select(\'col3\');
    $this->db->where(\'col1\',$some_var);
    
    $data = $this->db->get(\'some_table\');
    return $data->result();
}


Messages In This Thread
Need help with controller and accessing object - by El Forum - 06-21-2007, 04:56 AM
"Need help with controller and accessing object" - by El Forum - 06-21-2007, 05:11 AM
"Need help with controller and accessing object" - by El Forum - 06-21-2007, 06:29 AM
"Need help with controller and accessing object" - by El Forum - 06-21-2007, 07:31 AM



Theme © iAndrew 2016 - Forum software by © MyBB