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