[eluser]codex[/eluser]
[quote author="mb2007" date="1187120212"]Hello,
often I just request for one special database entry, so I use LIMIT 1. But the result with the CI function is a object so I use a foreach loop to display it. Is there a better way to access the array?
Code:
$this->db->select('some_row');
$this->db->where('some_other_row',$some_other_row_value);
$this->db->limit(1);
$query = $this->db->get('table');
foreach($query->result() as $row):
echo $row->some_row;
endforeach;
[/quote]
Hey,
this is what I struggled with the first time I started using CI (2 days ago).
Try this:
Code:
$this->db->select('some_row');
$this->db->from('table');
$this->db->where('some_other_row',$some_other_row_value);
$query = $this->db->get();
$query->result();
echo $query[0]->some_row;