Tharos / LeanMapper

Lean Mapper is a tiny ORM based on powerful Dibi database abstraction library for PHP.
MIT License
87 stars 35 forks source link

Entity: allow traversing in detached entity via HasOne relationship #92

Closed castamir closed 6 years ago

castamir commented 8 years ago

https://github.com/Tharos/LeanMapper/blob/develop/src/LeanMapper/Entity.php#L556-L558

/**
 * @property int $id
 * @property string $name
 */
class Author extends LeanMapper\Entity
{
}

/**
 * @property int $id
 * @property string $name
 * @property Author $author m:hasOne
 */
class Book extends LeanMapper\Entity
{
}

$author = new Author();
$author->name = 'Fowler';
$authorRepository->persist($author);

$book = new Book();
$book->author = $author;

$book->author->name;
janedbal commented 8 years ago

It is not so hard to implement this in some BaseEntity. Personally I'm using my own solution of this for maybe a year. You plan to support it natively?

castamir commented 8 years ago

Yes, exactly.

janpecha commented 6 years ago

Přidáno ve verzi 3.1 commitem 8612df2cfd019bdc55dd022a19ff67455cc012ee