hello i'm new in CodeIgniter, I've tried to read the documentation of CI but I still can't solve my problem, maybe someone here can help fix my problem. here my code:
$subdomain = $this->config->item('subdomain_name');
$instansi_id = $this->db->query("SELECT instansi_id FROM instansi WHERE subdomain = '$subdomain'");
$data = array(
'promosi' => $this->db->query("SELECT * FROM gallery WHERE gallery_status = 1 AND instansi_id = $instansi_id ORDER BY gallery_created DESC")->result(),
'slide' => $this->frontend->getSlide(),
),
i get an error like this: Object of class CI_DB_mysqli_result could not be converted to string
Maybe someone here can help to solve my problem ? Thanks.
In 2nd line you're getting query results which is an object [CI_DB_mysqli_result], but then you're just assuming it's a string in your next query.
$instansi_id = $this->db->query("SELECT instansi_id FROM instansi WHERE subdomain = '$subdomain'")->row()->instansi_id;
This should fix it.
If not, just
var_dump($instansi_id)
To see what's in it and proceed from there.