I don't see the wood for the trees, please point me into the right direction.
I've got a mysql query and retrieve the rows as objects. This works fine. Now, I want to populate an object's array with the values from the database. This object ($myobject) has several arrays (i.e. $myobject->field_1). These arrays contain (multiple) values for a certain field in various languages, hence it could be sth. like $myobject->field_1['en'][0] = 'value'. Here's what I tried to do:
$query = 'SELECT t.id, t.lang, t.val FROM table t';
$result = db_query($query); // custom db layer function
foreach ($result AS $row) {
$fieldname = 'field_'.$row->id;
$myobject->$fieldname[$row->lang][] = $row->val;
}
The last line is not working. Since I do not know, how many values are already stored for a language, I just want to add ([]) a value to the end of the array.
Which neat trick am I missing?
$result