just another orm...
View the Project on GitHub tflori/orm
» API Reference » ORM\Entity\Relations
public function addRelated(string $relation, \ORM\Entity[] $entities): mixed
This method is only for many-to-many relations.
This method does not take care about already existing relations and will fail hard.
Returns | mixed |
Parameter | Type | Description |
---|---|---|
$relation |
string | |
$entities |
ORM\Entity[] |
ORM\Entity\Relations::addRelated
public function deleteRelated(string $relation, \ORM\Entity[] $entities): mixed
This method is only for many-to-many relations.
Returns | mixed |
Parameter | Type | Description |
---|---|---|
$relation |
string | |
$entities |
ORM\Entity[] |
ORM\Entity\Relations::deleteRelated
public function fetch(
string $relation,
bool $getAll = false,
): \ORM\Entity|\ORM\Entity[]|\ORM\EntityFetcher
For relations with cardinality many it returns an EntityFetcher. Otherwise it returns the entity.
It will throw an error for non owner when the key is incomplete.
Returns | ORM\Entity|ORM\Entity[]|ORM\EntityFetcher |
Parameter | Type | Description |
---|---|---|
$relation |
string | The relation to fetch |
$getAll |
bool |
ORM\Entity\Relations::fetch
public function getRelated(string $relation, bool $refresh = false): mixed
The difference between getRelated and fetch is that getRelated stores the fetched entities. To refresh set $refresh to true.
Returns | mixed |
Parameter | Type | Description |
---|---|---|
$relation |
string | |
$refresh |
bool |
ORM\Entity\Relations::getRelated
public static function getRelation(string $name): \ORM\Relation
It normalize the short definition form and create a Relation object from it.
Static | This method is static. | |
Returns | ORM\Relation | |
Throws | ORM\Exception\UndefinedRelation |
Parameter | Type | Description |
---|---|---|
$name |
string |
ORM\Entity\Relations::getRelation
public function hasLoaded(string $relation): bool
Returns | bool |
Parameter | Type | Description |
---|---|---|
$relation |
string |
ORM\Entity\Relations::hasLoaded
public function load(string $relation): $this
Nested relations can be loaded by separating them by “.” for example load all articles with comments from
a user ($this): $user->load('articles.comments')
.
Returns | $this |
Parameter | Type | Description |
---|---|---|
$relation |
string |
ORM\Entity\Relations::load
public function resetRelated(null $relation = null): mixed
Helpful to reduce the size of serializations of the object (for caching, or toArray method etc.)
Returns | mixed |
Parameter | Type | Description |
---|---|---|
$relation |
null |
ORM\Entity\Relations::resetRelated
public function setRelated(string $relation, \ORM\Entity $entity = null): mixed
This method is only for the owner of a relation.
Returns | mixed |
Parameter | Type | Description |
---|---|---|
$relation |
string | |
$entity |
ORM\Entity |
ORM\Entity\Relations::setRelated