Array to string conversion is thrown when I try to get a specific id and don't let me save the form. i just need the id of 'intervaloHorario' in order to autofill a field,but i don't know what am i doing wrong. Please give me a hand.
Error
Severity: 4096
Message: Object of class stdClass could not be converted to string
Model function
public function get_idintervalo($idCitas) {
$query = $this->db->query('SELECT intervaloshorarios.idIntervaloHorario FROM intervaloshorarios INNER JOIN citas '
. 'ON intervaloshorarios.idIntervaloHorario = citas.idIntervaloHorario '
. 'WHERE citas.idCitas = ' . $idCitas . ';');
return $query->result();
}
Controller
$query = $this->Intervalos_Model->get_idintervalo($idCitas);
if ($crud->getState() == "add") {
//It's wroking fine getting this
$crud->change_field_type('idCitas', 'hidden', $idCitas);
foreach ($query as $key) {
//Is not working fine (throws array to string conversion)
$crud->change_field_type('idIntervaloHorario', 'hidden', $key);
}
gettype($query)to see the type of$queryvariable.