From e62d14a0f98b9532b686fab5b0a6c8002b6d5640 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Mon, 18 Aug 2025 20:06:57 -0400 Subject: [PATCH] Add example using splat operator with find() Fixes #8064 --- en/orm/retrieving-data-and-resultsets.rst | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/en/orm/retrieving-data-and-resultsets.rst b/en/orm/retrieving-data-and-resultsets.rst index b2a06083a7..1ba55adf00 100644 --- a/en/orm/retrieving-data-and-resultsets.rst +++ b/en/orm/retrieving-data-and-resultsets.rst @@ -145,6 +145,16 @@ You can also provide many commonly used options to ``find()``:: limit: 10 ); +If your finder options are in an array, you can use the `splat operator `_ (``...``) +to pass them into ``find()``:: + + $options = [ + 'conditions' => ['Articles.created >' => new DateTime('-10 days')], + 'contain' => ['Authors', 'Comments'], + 'limit' => 10, + ] + $query = $articles->find('all', ...$options); + The list of named arguments supported by find() by default are: - ``conditions`` provide conditions for the WHERE clause of your query. @@ -160,7 +170,7 @@ The list of named arguments supported by find() by default are: - ``join`` define additional custom joins. - ``order`` order the result set. -Any options that are not in this list will be passed to beforeFind listeners +Any options that are not in this list will be passed to ``beforeFind`` listeners where they can be used to modify the query object. You can use the ``getOptions()`` method on a query object to retrieve the options used. While you can pass query objects to your controllers, we recommend that you package