Hi!

I have an app with a few models; Claimant, Professional and
ApprovalRequisition among them.

Some of most important associations are:

- Claimant hasMany ApprovalRequisitions;
- Professional hasAndBelongsToMany ApprovalRequisition; and,
- ApprovalRequisition hasAndBelongsToMany Professional.

Starting from the ApprovalRequisition model, I need to retrieve all
Claimant's ApprovalRequisitions. Until now, no problem.

I'm using the code:

$claimant_approval_requisitions = $this->ApprovalRequisition->find(
    'all',
    array(
        'conditions' => array(
            'ApprovalRequisition.claimant_id' => $claimant_id
        )
    )
);

debug($claimant_approval_requisitions) shows:

Array(
    [0] => Array(
        [ApprovalRequisition] => Array(
            [id] => 1
            [created] => 2009-03-11 11:27:35
            [modified] => 2009-03-11 11:27:35
            [claimant_id] => 1
        )

        [Claimant] => Array(
            [id] => 1
            [created] => 2009-02-17 16:55:30
            [modified] => 2009-02-17 16:55:30
        )

        [Professional] => Array(
            [0] => Array(
                [id] => 2
                [created] => 2009-03-12 09:37:38
                [modified] => 2009-03-12 09:37:38
                [ApprovalRequisitionsProfessional] => Array(
                    [id] => 3
                    [created] => 2009-03-12 09:40:46
                    [modified] => 2009-03-12 09:40:46
                    [requisition_id] => 1
                    [professional_id] => 2
                )
            )

            [1] => Array(
                [id] => 1
                [created] => 2009-02-17 16:55:30
                [modified] => 2009-03-04 10:08:37
                [ApprovalRequisitionsProfessional] => Array(
                    [id] => 1
                    [created] => 2009-03-11 11:27:35
                    [modified] => 2009-03-11 11:27:35
                    [requisition_id] => 1
                    [professional_id] => 1
                )
            )
        )
    )

    [1] => Array(
        [ApprovalRequisition] => Array(
            [id] => 2
            [created] => 2009-03-12 11:26:01
            [modified] => 2009-03-12 11:26:01
            [claimant_id] => 1
        )

        [Claimant] => Array(
            [id] => 1
            [created] => 2009-02-17 16:55:30
            [modified] => 2009-02-17 16:55:30
        )

        [Professional] => Array(
            [0] => Array(
                [id] => 1
                [created] => 2009-02-17 16:55:30
                [modified] => 2009-03-04 10:08:37
                [ApprovalRequisitionsProfessional] => Array(
                    [id] => 4
                    [created] => 2009-03-12 11:26:01
                    [modified] => 2009-03-12 11:26:01
                    [requisition_id] => 2
                    [professional_id] => 1
                )
            )
        )
    )
)

My problem is retrieving all Professional's ApprovalRequisitions...

Basically, I wish to retrieve *ONLY* ApprovalRequisitions that belongs
to a given Professional. Simple like that.

Yes, I know that would be much more simple starting from the
Professional model to obtain all yours ApprovalRequisitions.

Can someone help me?

Thanks a lot.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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