Welcome Guest, Not a member yet? Register   Sign In
Object of class CI_DB_mysql_result could not be converted to string
#6

[eluser]andrewtheandroid[/eluser]
[quote author="Jan from Hamburg" date="1235317167"]Could you please explain how you solved it?
Got the same - Need a hint. Thank you!!![/quote]

I know this is an old post but for anyone else wondering how to solve this..

What the first reply meant was that you can't convert the query object to a result. To do this you need to use the result() or result_array() method in the
Generating Query Results userguide.

Example:
Where you are getting your result (eg. a model)
Code:
function getProfile($staffid) {
        // Perform query
        $query = $this->db->get_where('staff',array('staffid'=>$staffid));
        // Get result can also use result_array()
        return $query->result();
    }

Where you are parsing the results (eg. controller). and sending to view.
Code:
// Obtaining result
$result = $this->Staffmodel->getProfile($staffid);
// You may need to use this to get first result if your (if in doubt use var_dump())
$profile = $result[0];
// Load the parser
$this->load->library('parser');
// Parse contents (in this case set 'TRUE' if you want result in form of string)
$content = $this->parser->parse('templates/profile_tpl',$profile,TRUE);
// Send string to view and load view
$this->load->view('Template',array('content'=>$content));


Messages In This Thread
Object of class CI_DB_mysql_result could not be converted to string - by El Forum - 11-02-2009, 02:35 AM



Theme © iAndrew 2016 - Forum software by © MyBB