Hi,
I'm having a problem trying to save associated data that i get from
controller.
I'm using CakePHP 2.1
The main model (Order) doing good in saving more than one data.
But The problem is the associated model (Item) didnot save into the
database.
I hope you guys can help me....

The relationship is like this:
Order hasMany Item
Item belongsTo Order

Here is the my code:
$updates = $this->Order-
>find('all',array('conditions'=>array('Order.status_updated'=>1,'Order.branch_id'=>1)));
foreach($updates as $update):
        $update['Order']['status_updated'] = 0;
        #$this->Order->create();
        $this->Order->saveAssociated($update);
endforeach;

Here is the example data:
Array
(
    [0] => Array
        (
            [Order] => Array
                (
                    [id] => 66
                    [table] => 6
                    [date] => 2011-02-28 00:00:00
                    [branch_id] => 1
                    [status_updated] => 1
                )
            [Item] => Array
                (
                    [0] => Array
                        (
                            [id] => 16476
                            [order_id] => 66
                            [remark] =>
                            [branch_id] => 1
                        )
                )
        )
    [1] => Array
        (
            [Order] => Array
                (
                    [id] => 65
                    [table] => 1
                    [branch_id] => 1
                    [status_updated] => 1
                )
            [Item] => Array
                (
                    [0] => Array
                        (
                            [id] => 16478
                            [order_id] => 65
                            [remark] =>
                            [branch_id] => 1
                        )
                )
        )
)

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


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