[eluser]xwero[/eluser]
Try this
Code:
$this->db->select('t2.url, t2.title');
$this->db->from('exhibitions t1, galleries t2');
$this->db->where('t1.url',$this->uri->segment(3));
$this->db->where('t2.exhibitId = t1.exhibitionsId'); // silent join
$query = $this->db->get();
return $query->row();
It's a single sql statement with a silent join which outputs an object with the properties url and title.
If you are using the row method it outputs a one dimensional object so the foreach doesn't work. If you use it, it should be like this
Code:
$url = $this->uri->segment(3);
$this->db->select('exhibitionsId');
$this->db->from('exhibitions');
$this->db->where('url',$url);
$exhibitions_list = $this->db->get();
$row = $exhibitions_list->row();
$this->db->select('url, title');
$this->db->from('galleries');
$this->db->where('exhibitId', $row->exhibitionsId);
$galleryExhibitions_data = $this->db->get();
return $galleryExhibitions_data->result_array();