Welcome Guest, Not a member yet? Register   Sign In
getting array values
#1

[eluser]Fenix[/eluser]
I'd like to clear up (for me) how to access array results from a query in the most efficient/easy way. When I run a model function like this:

Code:
function get_values($post_id)
{
   $this->db->select('item1, item2, item3');
   $this->db->where('post_id', $post_id);
   $this->db->limit(1);
   return $this->db->get('posts')->result();
}

This way:

Code:
$result = $this->mymodel->get_values()

I'd like to be able to access the values like this:
Code:
$result->item1;
$result->item2;
$result->item3;

// or

$result['item1'];
$result['item2'];
$result['item3'];

Can anybody explain how to do this or something like this? Can anybody tell me what I'm doing wrong with either my model function or anything else?

Thanks


Messages In This Thread
getting array values - by El Forum - 11-08-2008, 05:27 PM
getting array values - by El Forum - 11-08-2008, 06:12 PM



Theme © iAndrew 2016 - Forum software by © MyBB