-- Nick Lo <[EMAIL PROTECTED]> wrote
(on Thursday, 17 January 2008, 11:07 AM +1100):
> This is probably more of an MVC issue but also a bit DB related too so I'm 
> posting here.
>
> Having just spent a few hair-pulling days (and nights) trying to nail down 
> a bug, I've (with the usual disclaimer) found the culprit to have been 
> Zend_Controller_Action::_forward().
>
> What I was doing was something like this (trimmed down):
>
> public function updateAction()
> {
>         $id = $filterInt->filter($this->_getParam('id'));
>         $data = array(
>             'ref'          => $this->_getParam('ref'),
>             'type'         => $this->_getParam('type'),
>             'title'        => $this->_getParam('title'),
>             'keywords'     => $this->_getParam('keywords'),
>             'description'  => $this->_getParam('description'),
>             'template'     => $this->_getParam('template'),
>             'ranking'      => $this->_getParam('ranking'),
>             'body'         => $this->_getParam('body')
>         );
>
>         $where = $this->_database->quoteInto('id = ?', $id);
>         $rows_affected = $this->_contentTable->update($data, $where);
>
>         // Some other bits were here but are innocent of wrongdoing
>
>         // Send back to the edit form
>         //$this->_forward('edit', 'content', null, array('id' => $id)); 
> <--- Here lies the culprit
>         $this->_redirect('/content/edit/id/' . $id); <--- Replacing with 
> this solved it
>  }
>
> What was happening was the database row would be updated but many of the 
> fields were blank.
>
> I'm currently using Zend_Layout but this was happening (seemingly 
> erratically) beforehand.
>
> So my question is: Why might this be happening?
>
> It suggests that _forward is somehow repeating the database update but 
> without the original _POST data?

Depends on what your ContentController::editAction() does -- and since
that's not in the code snippet above, I can't really give you an answer.

All _forward() does is dispatch another action. It does nothing with the
database, and it doesn't clear any request parameters. My guess is that
editAction() is doing something that alters the table. Send that method,
and perhaps I can be of more help.

-- 
Matthew Weier O'Phinney
PHP Developer            | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to