Here is my code, I should mention when inserting both the Topic and the
Post the problem occurs.

function new_topic($forum_id)
        {

                $this->set('forum_id', $forum_id);

                if(empty($this->data))
                {
                        $this->set('newtopic', null);
                }
                else
                {

                        $topic_valid = $this->Topic->validates($this->data);
                        $post_valid = $this->Post->validates($this->data);

                        if($topic_valid AND $post_valid) {

                                $this->data['Post']['topic_id'] = 0; // set to 
zero for time being

                                if($this->Post->save($this->data)) {
                                        $post_id = $this->Post->getInsertID();
                                        $this->data['Topic']['first_post_id'] = 
$post_id;
                                        $this->data['Topic']['forum_id'] = 
$forum_id;
                                        if($this->Topic->save($this->data)) {
                                                $topic_id = 
$this->Topic->getInsertID();
                                                $post = 
$this->Post->findById($post_id);
                                                $post['Post']['topic_id'] = 
$topic_id;
                                                $this->Post->save($post);

                                        }
                                }


                        }
                        else {
                                $this->validateErrors($this->Topic);
                                $this->validateErrors($this->Post);
                                $this->set('newtopic', $this->data);
                                $this->render();                                
        
                        }               
                }
        }


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply via email to