Search code examples
databasearrayszend-frameworkzend-db-table

array to Zend_Db_Table_Row zend framework


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!


Solution

  • 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);