Hello,

I'm probably just being dumb, but I can't seem to figure out
getLastInsertId when called from a Models afterSave method. Here's
what I thought should work:

$project_task_id = $this->getLastInsertId();

If i hard code in a value for $project_task_id then everything else
works and when I debug(this->getLastInsertId()) it's empty.

Any ideas? I'm in need of some schooling. Thanks in advance.

Heres the context:

class ProjectTask extends AppModel {

    var $name = 'ProjectTask';

    function afterSave($created) {
       /*
        *  Find all the ProjectTasks which are dependent
        *  on the task we just saved and update them to
        *  force a recalculation of the due date when beforeSave
        *  is called. This will cause a cascading set of
        *  updates to each successive task in the schedule
        */
        if (! $created) {
            $project_task_id = $this->getLastInsertId();
            // @todo - why is the above not returning anything?
            $dependentTasks = $this->findAll(
                "ProjectTask.depends_on ='$project_task_id'",
                NULL,
                NULL
            );
            foreach ($dependentTasks as $task) $this->save($task);
        }
        parent::afterSave($created);
    }
}
--~--~---------~--~----~------------~-------~--~----~
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