With native lazy loading support and partial objects as lazy objects, another feature that we could "easily" implement is marking columns as lazy, which would automatically make an entity a partial object.
<?php
#[Entity]
class Post
{
#[Id, GeneratedValue, Column(type: Types::INTEGER)]
public int $id;
#[Column]
public string $title;
#[Column, Lazy]
public string $body;
}
$post = $entityManager->find(Post::class, 1);
echo $post->title; // direct access
echo $post->body; // triggers lazy loading SELECT body FROM post WHERE id = 1
This also requires a way to specify that an object should be "FULLY" loaded from the beginning, i don't. have a complete idea on how to do that, multiple options:
- DQL keyword
SELECT FULL p FROM Post p
- Allow passing
$hints to finder methods, $entityManager->find(1, hints: [Query::HINT_FORCE_FULL_LOAD => true]) or ssomething similar.
Related: