$historyTable = new My_Model_CarHistory();
$historyRow = $historyTable->createRow($row->toArray());
$historyRow->save();
Regards,
Saša Stamenković
Hi,
Perhaps something like this-
$row = $this->find($id)->current();
$historyTable = new My_Model_CarHistory();
$historyRow = $historyTable->createRow($row->toArray());
$historyRow->save();
This assumes that you want the primary keys to be the same. Otherwise
you might have to do this:
$data = $row->toArray();
unset($data['id');
before inserting it into the createRow() method, to ensure that it gets
it's own database provided primary key.
Hope that helps,
Ralph
umpirsky wrote:
> Hi.
>
> I tried (in my class which extends Zend_Db_Table_Abstract):
>
> $row = $this->find($id)->current();
> $row->setTable(new My_Model_History());
> $row->save();
>
> My_Model_History and current class have same mysql structure, identical
> tables, one is active, and other I want to use for data history.
>
> I got:
>
> Zend_Db_Table_Row_Exception: Cannot refresh row as parent is missing
> thrown in Zend\Db\Table\Row\Abstract.php on line 758
>
> It works with:
>
> $row = $this->find($id)->current();
> $history = new My_Model_CarHistory();
> $history->insert($row->toArray());
>
> Is there a way to do it with sth similar to 1st example, or there is maybe
> some other better option?
>
> Regards,
> Sasa Stamenkovic.
View this message in context: Re: [fw-db] Select - insert Zend_Db_Row
Sent from the Zend DB mailing list archive at Nabble.com.