[eluser]ChrisMcABZ[/eluser]
Hi there. Forgive me if this has been covered already; I tried searching, but couldn't find what I was looking for.
I'm starting to roll my first CI application using 1.6.0 - it's a simple CMS for my personal site. What I would like to do is this (code shortened for berevity):
(model)
Code:
public function GetBySlug($slug='')
{
$entry['slug'] = $slug;
return $this->db->get_where('entries', $entry)->result();
}
(controller)
Code:
$data['entry'] = $this->Entry->GetBySlug($slug);
$this->load->view('entry', $data['entry']);
(view)
Code:
<h1><?= $entry->title; ?></h1>
But with this code I just get an error. If I write this instead -
Code:
<h1><?= $entry[0]->title; ?></h1>
or use a loop, it works, but that seems a waste for what will always be a single result - and it's not as pretty

. Am I missing something (probably something very basic!)? Or do I have to give up my objects in views and start passing result_array() instead?
Thanks in advance, CI Bods!