I'm looking for a way to return an array from the database query, but only for the first row. I'd prefer not to use objects..
My current solution:
//Gather
$data = $this->db->from('view')->where('alias', $alias)->get()->result_array();
//Collect the first row only
$data = $data[0];
Which is pretty ugly to be honest. As said, I'd prefer to not use objects.
Use the row()
method instead:
$data = $this->db->from('view')->where('alias', $alias)->get()->row();
[Oh, you don't want to use objects. row_array()
then. But consider objects.]