Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions en/orm/retrieving-data-and-resultsets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ viewing entities and their related data. You can do this by using ``get()``::
$article = $articles->get($id);

// Get a single article, and related comments
$article = $articles->get($id, [
'contain' => ['Comments'],
]);
$article = $articles->get($id, contain: ['Comments']);

If the get operation does not find any results a
``Cake\Datasource\Exception\RecordNotFoundException`` will be raised. You can
Expand All @@ -56,27 +54,19 @@ Like ``find()``, ``get()`` also has caching integrated. You can use the
// In a controller or table method.

// Use any cache config or CacheEngine instance & a generated key
$article = $articles->get($id, [
'cache' => 'custom',
]);
$article = $articles->get($id, cache: 'custom');

// Use any cache config or CacheEngine instance & specific key
$article = $articles->get($id, [
'cache' => 'custom', 'key' => 'mykey'
]);
$article = $articles->get($id, cache: 'custom', key: 'mykey');

// Explicitly disable caching
$article = $articles->get($id, [
'cache' => false
]);
$article = $articles->get($id, cache: false);

Optionally you can ``get()`` an entity using :ref:`custom-find-methods`. For
example you may want to get all translations for an entity. You can achieve that
by using the ``finder`` option::

$article = $articles->get($id, [
'finder' => 'translations',
]);
$article = $articles->get($id, 'translations');

The list of options supported by get() are:

Expand Down