Magento: make PDO results into a Varien object

I have a stored procedure that I call when using 'core_read' and the request method. Then the results are collected using fetchAll (PDO :: FETCH_ASSOC).

The data is displayed perfectly. I can do foreach in the array and access the data using the keys of the array ($ row ['name']).

I would like to convert the associative array to Varien_Object, so I could access the data using the notation $ row-> getName () ... Saving in Magento style ... How would I perform such a conversion, if possible?

+3
source share
3 answers

, , , . :

foreach($rows as $row) {
   $orders[] = new Varien_Object($row);
}
+1

Varien_Object

$object = new Varien_Object($array);

. lib/varien/object

+4

I think you can just use:

foreach($rows as $row) {
    $object = new Varien_Object();
    $object->setData($row);
}
+3
source

All Articles