Cannot use object of type stdClass as array |
[eluser]xerosis[/eluser]
In my controller I am calling a model which takes data from a database: Code: $spec_info = $this->spec_model->GetSpecs(array("id" => $this->input->post('image_spec_id')), 'width, height'); This ends up with the error: "Cannot use object of type stdClass as array" How am I supposed to write it so it works? Below is the code for my spec_model Code: function GetSpecs($options = array(), $require = NULL)
[eluser]toopay[/eluser]
two option, return the array instead object, on your model Code: return $query->result_array(); Code: $spec_info = (array) $this->spec_model->GetSpecs(array("id" => $this->input->post('image_spec_id')), 'width, height');
[eluser]toopay[/eluser]
For better understanding, you may want to read types in php : http://www.php.net/manual/en/language.types.php |
Welcome Guest, Not a member yet? Register Sign In |