Hello, I have a dumb question to ask but strangely enough my search results for it have turned up null.
I want to do some PHP manipulation on my dataobject contents rather than just display it on a page. To do this, I often need to convert my dataobjects into arrays as I find it easier to access and manipulate array properties than dataobject properties
I use a function like this to do it:
$array = array();
$result = Dataobject::get("table");
foreach ($result as $row) {
$array[$row->field] = $row->field;
//do something like this for every field
}
return $array;
My question is if there is a Silverstripe feature that already returns Database data as a regular array. If one exists, I can skip this step altogether but I am having trouble finding it.
Surely Silverstripe has something that does this. I just haven't found it yet.