Hi there,

I'm joining a link table via bindModel to manipulate extra data in the link table. The php code below is called from the 'Quote' model.
The associations before the bind are as follows:
Quote belongsTo Customer
Quote belongsTo User
Quote HABTM StockedItem (link table 'items_quotes')
Quote HABTM Service (link table 'items_services')


<?php
		$this->bindModel(array(
				'hasMany' => array(
					'ItemsQuote' => array(
						'fields' => 'quote_id,
								item_id,
								quantity,
								item_unit_price_quoted,
								item_discount_percent'))));
											
		$quote_items = $this->findAll('Quote.id = ' . $quote_id);
?>

"Gives the following, which is far too much info. I'm really only interested the 'ItemsQuote' array in lines 57 through 77."

Array
(
    [0] => Array
        (
            [Quote] => Array
                (
                    [id] => 21
                    [customer_id] => 999999
                    [field1] => value1
                    [field2] => value2
                    [field3] => value3
                    [created] => 2006-08-15 04:29:02
                    [modified] => 2006-08-15 04:29:02
                )

            [Customer] => Array
                (
                    [id] => 
                    [account_number] => 
                    [first_name] =>
                    [field1] => 
                    [field2] => 
                    [field3] => 
                    [created] => 
                    [modified] => 
                )

            [User] => Array
                (
                    [id] => 1
                    [first_name] => Bob
                    [last_name] => Byrne
                    [username] => bobby
                    [password] => bobbypass
                    [type] => cashier
                )

// line 57 [ItemsQuote] => Array
                (
                    [0] => Array
                        (
                            [quote_id] => 21
                            [item_id] => 2
                            [quantity] => 4
                            [item_unit_price_quoted] => 46.50
                            [item_discount_percent] => 10
                        )

                    [1] => Array
                        (
                            [quote_id] => 21
                            [item_id] => 3
                            [quantity] => 63
                            [item_unit_price_quoted] => 44.00
                            [item_discount_percent] => 0
                        )

// Line 57     )

            [StockedItem] => Array
                (
                    [0] => Array
                        (
                            [id] => 1
                            [item_id] => 10009
                            [supplier_id] => 1
                            [quantity] => 10
                            [unit_price] => 46.50
                            [buy_price] => 46.00
                            [created] => 9999-12-31 23:59:59
                            [modified] => 9999-12-31 23:59:59
                        )

                    [1] => Array
                        (
                            [id] => 2
                            [item_id] => 10009
                            [supplier_id] => 1
                            [quantity] => 15
                            [unit_price] => 45.50
                            [buy_price] => 41.00
                            [created] => 9999-12-31 23:59:58
                            [modified] => 9999-12-31 23:59:58
                        )

                    [2] => Array
                        (
                            [id] => 3
                            [item_id] => 10009
                            [supplier_id] => 2
                            [quantity] => 20
                            [unit_price] => 44.00
                            [buy_price] => 40.50
                            [created] => 9999-12-31 23:59:57
                            [modified] => 9999-12-31 23:59:57
                        )

                )

            [Service] => Array
                (
                )

        )

)

"The second method below gives me a smaller output buy in an awkward array structure.
Method 2:"
<?php
        $quote_items = $this->ItemsQuote->findAll('quote_id = ' . $quote_id);
>?
"Gives the following smaller array but the parent index is now numberic with a child index 'ItemsQuote'. Why doesn't this give the 'ItemsQuote' array structure as in lines 57 through 77 above?"

Array
(
    [0] => Array
        (
            [ItemsQuote] => Array
                (
                    [quote_id] => 21
                    [item_id] => 2
                    [quantity] => 4
                    [item_unit_price_quoted] => 46.50
                    [item_discount_percent] => 10
                    [created] => 2006-08-30 15:36:10
                    [modified] => 2006-08-30 15:36:10
                )

        )

    [1] => Array
        (
            [ItemsQuote] => Array
                (
                    [quote_id] => 21
                    [item_id] => 3
                    [quantity] => 63
                    [item_unit_price_quoted] => 44.00
                    [item_discount_percent] => 0
                    [created] => 2006-08-30 14:02:22
                    [modified] => 2006-08-30 14:02:22
                )

        )

)

Cheers,

Sonic

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply via email to