I have a variable called $result which should store all the results from my database query however when I run print ($result) it gives an error message:
A PHP Error was encountered
Severity: 4096
Message: Object of class CI_DB_mysql_result could not be converted to string
Filename: models/control_panel_model.php
Line Number: 72
Here is my model code:
public function view_record($record_id)
{
$criteria = array
(
'procedure_id' => $record_id
);
echo $this->db->count_all('procedure');
return;
$this->db->select('procedure.procedure_id, procedure.patient_id, procedure.department_id, procedure.name_id , procedure.dosage_id');
$this->db->from ('procedure');
$this->db->join('patient', 'patient.patient_id = procedure.patient_id', 'inner');
$this->db->join('department', 'department.department_id = procedure.department_id', 'inner');
$this->db->join('procedure_name', 'procedure_name.procedure_name_id = procedure.name_id', 'inner');
$this->db->join('dosage', 'dosage.dosage_id = procedure.dosage_id', 'inner');
$this->db->where('procedure_id', $record_id);
$result = $this->db->get();
print($result);
return ;
}
The reason I am using a print function is just to test if my query is working and it has values. How do I achieve this.
Thanks
EDIT!!!
Here is what I get in var_dump();
object(CI_DB_mysql_result)#22 (8) {
["conn_id"]=> resource(30) of type (mysql link persistent)
["result_id"]=> resource(40) of type (mysql result)
["result_array"]=> array(0) { }
["result_object"]=> array(0) { }
["custom_result_object"]=> array(0) { }
["current_row"]=> int(0)
["num_rows"]=> int(0)
["row_data"]=> NULL
}
I HAVE ADDED THE FOLLOWING CODE:
if ($result->num_rows >0) { echo "Data"; } else { echo "No Data"; }
IT IS SAYING THERE IS "NO DATA" so my query must be crap and wrong , so I need to redesign query. THERE IS DATA IN MY DATABASE SO must be query
===========================================
Here is my schema http://i.imgur.com/Dju0G.png
