Welcome Guest, Not a member yet? Register   Sign In
Get value from object

Probably a very old chestnut but I can't find an answer by searching the forum.

I have an object $record derived from a db. When I run print_r($record) I get:

stdClass Object ( [id] => 4 [qty] => 0 [price] => 3.00 [name] => default [filename] => MH0005.jpg [cat] => agriculture [description] => nil)

so the model is working OK. But now, within a controller method, how can I grab the value of any one of the elements?

I've tried each of these:

$id = $record['id'];
$id = $record[0];
$id = $record->result('id');

but it throws an error every time.

Theme © iAndrew 2016 - Forum software by © MyBB