Friday, 5 September 2014

Save multiple rows record in cakephp


You can also use this format to save several records and their HABTM associations with saveAll(), using an array like the following:

Array
(
    [0] => Array
        (
            [Note] => Array
                (
                    [id] => 0
                    [company_id] => 53218f2c-91f8-4168-a1d6-09b50a28b132
                    [cid] => 53199bf6-2e78-43c2-8a08-084f0a28b132
                    [author] => vh admin
                    [notedate] => 2014-09-05
                    [time] => 16:08:46
                    [type] => client
                    [type_id] => 53199bf6-2e78-43c2-8a08-084f0a28b132
                    [subject] => Inactivated
                    [reason] => Feedback issues
                    [message] => Views are the presentation layer in CakePHP. They convert the data fetched from Models into the output format requested by the client. Read more about 
                )

        )

    [1] => Array
        (
            [Note] => Array
                (
                    [id] => 0
                    [company_id] => 53199bf6-3760-4666-89d6-084f0a28b132
                    [cid] => 53218f2c-cbb8-49dc-bf3a-09b50a28b132
                    [author] => vh admin
                    [notedate] => 2014-09-05
                    [time] => 16:08:46
                    [type] => client
                    [type_id] => 53218f2c-cbb8-49dc-bf3a-09b50a28b132
                    [subject] => Inactivated
                    [reason] => Feedback issues
                    [message] => Views are the presentation layer in CakePHP. They convert the data fetched from Models into the output format requested by the client. Read more about 
                )

        )

)
$this->Note->create();
$this->Note->saveAll($this->data)

0 comments:

Post a Comment