Download the PHP package goldfinch/eagerloading without Composer
On this page you can find all versions of the php package goldfinch/eagerloading. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download goldfinch/eagerloading
More information about goldfinch/eagerloading
Files in goldfinch/eagerloading
Package eagerloading
Short Description Eager loading for SilverStripe 4
License BSD-3-Clause
Informations about the package eagerloading
Silverstripe EagerLoading
Attempt to solve N+1 problem in SilverStripe 4.
Usage
It does not require huge configuration - only one function to be added to the query builder chain : ->with([..relations...])
.
This will result in the final DataList to be presented by the EagerLoadedDataList
class that handles the eager loading.
The module takes advantage of DataList::getGenerator()
to query for and attach the related records only when needed.
Installation
Every DataObject that has has_one/many_many/belongs_many_many which you wish to have eagerloaded must include EagerLoaderMultiAccessor
(see below).
Features
- Using with $has_one / $belongs_to
- Using with $has_many / $many_many / $belongs_many_many
- Boosting GridField output
- Boosting CSV export
Read the docs for full explanation.
Quick start
1. Add the following trait to all your models to use $has_many
, $many_many
, $belongs_meny_many
:
If you have your own __call()
read Using with $has_many/$many_many.
2. Declare private static $eager_loading
to boost ModelAdmin's GridField output.
TODO
- for
->with(['RelLevel1.RelLevel2'])
- do not query forRelLevel1
IDs twice. - for
->with(['RelLevel1','RelLevel1.RelLevel2'])
- do not query forRelLevel1
IDs thrice.
Reporting Issues
Please create an issue for any bugs you've found, or features you're missing.