hi franck tnx what i am trying to achieve is that when a new
membership record is created a new tasklist record must be created.
That is why i used the aftersave, but as you pointed out this will run
after an update too, so its not really ideal, how should i do this
instead? handling the membership_id in the function where i save is a
good idea but this ties in with the previous point i.e. im not sure
how i should go about implementing this functionality. any futher help
would be appreciated thnx

On Aug 2, 6:21 am, francky06l <[EMAIL PROTECTED]> wrote:
> well, I am a bit lost. I do not know what you want to achieve. Just
> few comments :
>
> - in your finddata() you should try to use the Cake convention  with
> findAll
> - afterSave() will be called also when you update data, it does not
> seems to be the right place to handle the inserted Id.
> - Why not handling the membership_id in the function where you
> actually call save() ?
>
> Again, I do not know what you want to achieve, but the overall
> approach seems weird regarding the code posted here.
>
> On Aug 2, 12:16 am, rtanz <[EMAIL PROTECTED]> wrote:
>
> > thanks so i reviewed my code, the remaining problems are:
> > 1. $membership_id is not being passed correctly
> > 2. im not sure how to save the returned arrays into tasklist records
> > any help on this? thanks
>
> > <?php
>
> > class Membership extends AppModel
> > {
> >     var $name = 'Membership';
> >         var $belongsTo = array('Module','Role','User');
>
> >         function afterSave()    {
> >                 $membership_id = $this->getLastInsertId();
> >                 //$membership_id = 1; //getlastid
> >                 $this->requestAction('tasklists/add/$membership_id');
> >                 return true;
> >         }
>
> > }
>
> > ?>
>
> > Tasklist controller:
>
> >         function add($membership_id) {
> >         $tasklists = $this->Tasklist->finddata($membership_id);
> >         $this->set('tasklists',$tasklists);
>
> > }
>
> > class Tasklist extends AppModel
> > {
> >     var $name = 'Tasklist';
> >         var $belongsTo = array('Module','Task','User');
>
> >         function finddata($membership_id) {
>
> >         return $this->query("SELECT
> > `memberships`.`module_id`,`memberships`.`user_id`, `tasks`.`id`as
> > task_id
> >                                                                 FROM 
> > `memberships` , `tasks`
> >                                                                 WHERE 
> > `tasks`.`role_id` =  `memberships`.`role_id` AND
> > `memberships`.`id`=$membership_id");
> >                                         //              debug($ret);
>
> >         return $ret;
> >         }
>
> > }
>
> > ?>


--~--~---------~--~----~------------~-------~--~----~
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