Well, since you need the "review_id" when saving the module, then it
needs to be created first.  You should probably do this in the Module
beforeSave, ie:


function beforeSave()
{
        if ( empty($this->id) and empty($this->data[$this->name]['id']) ){
                // we are inserting a new Module, create the associated Review
                $review_data = array( 'reviewtext'=>'No Review Yet!' );
                $this->Review->save( array('Review'=>$review_data) );
                $this->data[$this->name]['review_id'] = $this->Review->id;
        }
        return parent::beforeSave();
}


On Jul 23, 9:31 pm, rtanz <[EMAIL PROTECTED]> wrote:
> i have a table MODULES containing fields:
> id
> name
> review_id
>
> and another table REVIEWS containing fields:
> id
> reviewtext
>
> i would like that when a new module is created the review_id is auto
> incremented and a new record in the review table created with that new
> review_id as its primary id key. how can i do this? thanks


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

Reply via email to