Hi,
I have 4 tables.
people
    id
    name

foods
    id
    name
    shopid

shops
    id
    name

orders
    id
    peopleid
    foodid

In my application, 1 order has 1 food, 1 shop has many foods, 1 people
has many orders

Models:
//People
var $hasMany = array(
        'Order' => array(
            'className' => 'Order',
            'foreignKey' => 'peopleId'
        )
    );

//Food
var $belongsTo = array(
        'Shop' => array(
            'className' => 'Shop',
            'foreignKey' => 'shopId'
        )
    );

//Shop
var $hasMany = array(
        'Food' => array(
            'className' => 'Food',
            'foreignKey' => 'shopId'
        )
    );

//Order
var $belongsTo = array(
        'People' => array(
            'className' => 'People',
            'foreignKey' => 'peopleId'
        ),
        'Food' => array(
            'className' => 'Food',
            'foreignKey' => 'foodId'
        )
    );


I think the relationship is right, because when I use $this->Order-
>findAll()

I get an array like this
Array
(
    [0] => Array
        (
            [Order] => Array
                (
                    [id] => 1
                    [peopleId] => 1
                    [foodId] => 1
                    [created] =>
                    [modified] =>
                    [isPaid] =>
                    [shopId] => 1
                    [count] => 3
                )

            [People] => Array
                (
                    [id] => 1
                    [name] => Roger
                    [email] => [EMAIL PROTECTED]
                )

            [Food] => Array
                (
                    [id] => 1
                    [name] => Beef
                    [price] => 15.5
                    [shopId] => 1
                )
        )
)

But, when I get all orders, I can't get shop information. So I want to
get an array like this:
Array
(
    [0] => Array
        (
            [Order] => Array
                (
                    [id] => 1
                    [peopleId] => 1
                    [foodId] => 1
                    [created] =>
                    [modified] =>
                    [isPaid] =>
                    [shopId] => 1
                    [count] => 3
                )

            [People] => Array
                (
                    [id] => 1
                    [name] => Roger
                    [email] => [EMAIL PROTECTED]
                )

            [Food] => Array
                 (
                         [id] => 1
                         [name] => Beef
                         [price] => 15.5
                         [shopId] => 1
                         [shop] = Array
                                (
                                          [id] => 1
                                          [name] => Beef
                                )
                 )

        )


How can I get this or something like this?

Thanks.

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