Reputation: 1410
I have to make a rather complicated query to my database and at it seems that extbase queries cannot do what I need (for example, I need all categories with article-count > 0). So I created a query and execute it with exec_SELECTgetRows - now, is there a way to map the result back to entities?
I'd be thankful for any hints.
Upvotes: 4
Views: 671
Reputation: 3228
You can achieve this by manually triggering PropertyMapper
. Check the Flow docs about it. The concept is 1:1 same in ExtBase.
Some example code in your case may be following:
$objectStorage = $this->objectManager->get(ObjectStorage::class);
$propertyMapper = $this->objectManager->get(PropertyMapper::class);
$dataArray = $this->db->exec_SELECTgetRows(...);
foreach($dataArray as $data) {
$dataObject = $propertyMapper->convert($data, \Your\Custom\Object::class);
$objectStorage->attach($dataObject);
}
Upvotes: 6