Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
| framework-web:symfony:models:crud [2018/02/05 11:15] – [Repository] jcheron | framework-web:symfony:models:crud [2019/08/31 14:21] (Version actuelle) – modification externe 127.0.0.1 | ||
|---|---|---|---|
| Ligne 51: | Ligne 51: | ||
| } | } | ||
| </ | </ | ||
| + | |||
| + | ===== Read : chargement d' | ||
| + | |||
| + | Récupération du Repository : | ||
| + | <sxh php> | ||
| + | $repository = $this-> | ||
| + | </ | ||
| + | |||
| + | Chargement d'une instance (par sa clé primaire, généralement ' | ||
| + | <sxh php> | ||
| + | $product = $repository-> | ||
| + | </ | ||
| + | |||
| + | Chargement d'une instance sur critères variés : | ||
| + | <sxh php> | ||
| + | // query for a single Product by name | ||
| + | $product = $repository-> | ||
| + | // or find by name and price | ||
| + | $product = $repository-> | ||
| + | ' | ||
| + | ' | ||
| + | ]); | ||
| + | </ | ||
| + | |||
| + | Chargement de plusieurs instances | ||
| + | |||
| + | <sxh php> | ||
| + | // query for multiple Product objects matching the name, ordered by price | ||
| + | $products = $repository-> | ||
| + | [' | ||
| + | [' | ||
| + | ); | ||
| + | |||
| + | // find *all* Product objects | ||
| + | $products = $repository-> | ||
| + | </ | ||
| + | |||