Skip to content

Commit

Permalink
Merge pull request #4181 from cakephp/savemany
Browse files Browse the repository at this point in the history
Add info about Table::saveMany()
  • Loading branch information
markstory committed Jul 18, 2016
2 parents c2f71f6 + 159bf30 commit 9afebb6
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions en/orm/saving-data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,33 @@ receiving from the end user is the correct type. Failing to correctly handle
complex data could result in malicious users being able to store data they
would not normally be able to.

Saving Multiple Entities
========================

.. php:method:: saveMany($entities, $options = [])
Using this method you can save multiple entities atomically. ``$entites`` can
be an array of entities created using ``newEntities()`` / ``patchEntities()``.
``$options`` can have the same options as accepted by ``save()``::

$data = [
[
'title' => 'First post',
'published' => 1
],
[
'title' => 'Second post',
'published' => 1
],
];
$articles = TableRegistry::get('Articles');
$entities = $articles->newEntities($data);
$result = $articles->saveMany($entities);

The result will be updated entities on success or ``false`` on failure.

.. versionadded:: 3.2.8

Bulk Updates
============
Expand Down

0 comments on commit 9afebb6

Please sign in to comment.