Skip to content

Commit

Permalink
Merge pull request #7771 from nitramxx/patch-1
Browse files Browse the repository at this point in the history
Update Table::get() params in docs from array to named args
  • Loading branch information
markstory authored Nov 20, 2023
2 parents b535c9b + 53a1c08 commit 0195622
Showing 1 changed file with 5 additions and 15 deletions.
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

0 comments on commit 0195622

Please sign in to comment.