Dalibor Karlović wrote:
>
> On Friday 29 May 2009 18:24:00 Jalil F. wrote:
>> I am very new to Zend. I have a Books model object that extends
>> Zend_Db_Table. In my controller, I create a new row like this:
>>
>> $t = new Books();
>> $row = $t->createRow();
>> $row->name = $form->getValue('name');
>> $row->save();
>>
>>
>> My table has an ID column that is the primary key and is automatically
>> incremented. How can I get back the ID of the row I just created and
>> saved?
>
> $id = $row->save();
>
> --
> Dado
>
>
Dado, your solution it works. But i have another problem: after getting my
id i want to put it to my hidden element, but setValue() method doesn't
work.
if ($this->getRequest()->isPost()) {
$formData = $this->_request->getPost();
if ($form->isValid($formData)) {
...
$requests = new Model_DbTable_Requests();
$new_id = $requests->addRequest($reqName, $type, $request);
$form->idx->setValue($new_id);
}
$this->_forward('question');
}
any ideas?
--
View this message in context:
http://www.nabble.com/How-to-get-row-ID-back-when-using-Save-tp23782987p24516385.html
Sent from the Zend Framework mailing list archive at Nabble.com.