Array in Zend_Db_Table_Row zend framework

Is there a way to automatically convert from an array to Zend_Db_Table_Row or Zend_Db_Table_Rowset?

The Zend_Db_Table_Row form, you can get an array using the toArray () parameter, but I was wondering if something like the opposite is coming out?

So far, I have implemented the fill ($ data) function, which took an array and set the Zend_Db_Table_Row attributes.

Of course, the keys of the array match the attributes of Zend_Db_Table_Row.

Thanx!

+4
source share
2 answers

Check out the Zend_Db_Table fetchRow () method. There you can find it. I think you can pass the array to the constructor as follows:

$data = array( 'table' => $yourDbTableModel, 'data' => $yourArray, 'readOnly' => $iGuessShouldBeZero, 'stored' => true ); $row = new Zend_Db_Table_Row($data); 
+5
source

I think this should do the trick:

 $myRow = new Zend_Db_Table_Row( array( 'data' => array( /* your array with data */ ) ) ); 

So, if you provide the constructor with a configuration array that contains the "data" key, which will contain the data array in it, you should be good.

See the Zend_Db_Table_Row_Abstract in your Zend library for more information.

+2
source

All Articles