4

is there a way of automatic converting from array to Zend_Db_Table_Row or Zend_Db_Table_Rowset?

Form Zend_Db_Table_Row you can get the array with toArray(), but I was wondering if there exits anything like opposite of that?

Till now I have been implementing a function fill($data) which took the array and than set the atributes of Zend_Db_Table_Row.

Of course array keys are the same as Zend_Db_Table_Row attributes.

Thanx!

2 Answers 2

5

Check the Zend_Db_Table's fetchRow() method. There you can find it. I guess you can feed the array to the constructor like this:

$data = array(
        'table'   => $yourDbTableModel,
        'data'     => $yourArray,
        'readOnly' => $iGuessShouldBeZero,
        'stored'  => true
    );
$row = new Zend_Db_Table_Row($data);
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! both of you answers are very good! You both solved my problem!
2

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 config array that holds a key 'data' that in it's turn holds an array with the data, you should be good.

For more info look into Zend_Db_Table_Row_Abstract in your Zend library.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.