In my model I have the follow query:
function myquerydata() {
$data = array();
$query = $this->db->query('select max(field1) as field11, max(field2) as field22, max(field3) as field33 from my_table');
foreach ($query->result() as $row) {
$row->field11;
$row->field22;
$row->field33;
}
}
This query only return one row.
In my controller I have the next code:
$this->load->model('my_model');
$fields=$data['rows']=$this->my_model->myquerydata();
My question is how can I call the data field11, field22, field33 from controller. When I apply a foreach appears error:
foreach ($fields as $row){
echo $row->field11,
echo $row->field22,
echo $row->field33,
}
What is my error?
Do this:
And place the following in your controller