On Thu, Apr 16, 2009 at 9:53 PM, Derk <[email protected]> wrote:
>
> nobody?
>
> Derk wrote:
>>
>> There are two tables involved
>>
>> articles
>> - id
>> - title
>> - text
>>
>> comments
>> - name
>> - comment
>> - article_id
>>
>> Now I have a form by an article, so users can post comments
>>
>> The code is quite simple...
>>
>>     public function showAction() {
>>               $articlesTable = new Articles;
>>               $article = $articlesTable->fetchRow("REPLACE(title, ' ', '-') 
>> = '" .
>> $this->_getParam('article') . "'");
>>
>>               // comments
>>               $this->view->comments = $article->findComments();
>>
>>               // comment form
>>               // create form.....
>>
>>               $this->view->form = $form;
>>
>>               if($this->getRequest()->isPost()) {
>>
>>                       if($form->isValid($_POST)) {
>>                               $commentsTable = new Comments();
>>                               $comment = 
>> $commentsTable->createRow($form->getValues());
>>                               $comment->article_id = $article->id;
>>                               $comment->save();
>>                       }
>>               }
>>
>>       }
>>
>> when I post a comment I get: "Cannot refresh row as parent is missing"
>> stack trace:
>> #0 ...\library\Zend\Db\Table\Row\Abstract.php(475):
>> Zend_Db_Table_Row_Abstract->_refresh()
>> ....
>>
>> But the comment is saved in the right way..
>>
>> How can I solve this?
>>
>> Thanks for your help
>>
>

I'm guessing the Comments model is missing the primary key.

Till

Reply via email to