@@ -117,7 +117,6 @@ final class UserMapper extends EntityRecordMapper
117
117
);
118
118
}
119
119
}
120
-
121
120
```
122
121
123
122
### Nullable Support
@@ -127,8 +126,8 @@ values in your database rows.
127
126
128
127
### Foreign keys and objects
129
128
130
- The orm does not resolve foreign keys and objects automatically,
131
- instead you have to inject the object repository and load as needed:
129
+ The ORM does not resolve foreign keys and objects automatically.
130
+ Instead, you must inject the object repository and load the object as needed:
132
131
133
132
``` php
134
133
return new User(
@@ -142,7 +141,8 @@ return new User(
142
141
143
142
### Lazy loading
144
143
145
- Records can be lazy loaded with ` lazyOf ` function, which receives an initializer and loads the entry only when any of its properties are called:
144
+ Records can be lazy-loaded with the ` lazyOf ` function, which receives an initializer and loads the entry only when any of its properties are accessed:
145
+
146
146
``` php
147
147
/** lazy object */
148
148
$address = lazyOf(
@@ -158,24 +158,24 @@ $street = $address->street;
158
158
159
159
### Solving N+1 problems
160
160
161
- N+1 can be solved with ` lazyBufferOf ` function, it manages buffered and loaded records,
162
- all buffered records are loaded at once when any of the entries are loaded ,
163
- and all loaded records are returned right away without additional loader calls
161
+ N+1 can be solved with the ` lazyBufferOf ` function, which manages buffered and loaded records.
162
+ All buffered records are loaded at once when any of the entries are accessed ,
163
+ and all previously loaded records are returned immediately without additional loader calls.
164
164
165
165
``` php
166
166
$addressLoader = lazyBufferOf(
167
167
/** The class to be loaded */
168
168
Address::class,
169
169
/** The object list loader */
170
170
function (array $bufferedIds) {
171
- listOf($this->addressRepository->loadAllByIds($ids ))
171
+ listOf($this->addressRepository->loadAllByIds($bufferedIds ))
172
172
->indexedBy(fn(Address $address) => $address->id)
173
- ->entries()
173
+ ->entries();
174
174
},
175
175
);
176
176
177
177
/** lazy object */
178
- $address = $addressLoader->lazyOf($addressId),
178
+ $address = $addressLoader->lazyOf($addressId);
179
179
180
180
/** loaded object */
181
181
$street = $address->street;
@@ -261,6 +261,7 @@ Contributions are welcome! If you have ideas, find a bug, or want to improve the
261
261
Please follow PSR-12 coding standards and ensure tests pass before submitting changes.
262
262
263
263
## 🚀 Next steps
264
+
264
265
- Query builder
265
266
- Extend where comparisons
266
267
0 commit comments