You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to untangle the joins with a solution like $conditions in QueryBuilder.
I've often run into the problem that it would be nice to be able to attach a table without always having to create an attachment table, this example is a problem for me apart from the names.
class OneToManyEntity {
#[ORM\Id, ORM\GeneratedValue, ORM\Column]
private ?int $id = null;
#[ORM\OneToMany(
targetEntity: Storage::class,
conditions: [
'target.entityClass' => 'etc...' OR
'target.entityClass' => OneToManyEntity::class OR -> sql example below
'target.entityClass' => 'self.other colums' OR
'self.other colum' => FooBarEnumClass::VALUE
Or even Doctrine\ORM\Query\Exy\Expr\Comparison or something similar
]
)]
private Collection $storages;
public function __construct()
{
$this->storages = new ArrayCollection();
}
}
SQL example:
SELECT * FROM OneToManyEntity LEFT JOIN Storage ON (OneToManyEntity.id = Storage.entityId AND Storage.entityClass = 'App\Entity\OneToManyEntity')
The "target" and "self" in the conditions array would refer to the table in question.
In the case of OneToManyEntity, the query builder would substitute the name of the storage table for "target" and the name of the OneToManyEntity table for "self".
Of course this would be useful for multiple tables, like in my case where I have about 10 tables connected to the Storage table, but I don't want to put 10 separate ids on the Storage table
Which is a big question how "mappedBy" and "inversedBy" could be used, but I guess not :(
The text was updated successfully, but these errors were encountered:
Feature Request
Summary
I would like to untangle the joins with a solution like $conditions in QueryBuilder.
I've often run into the problem that it would be nice to be able to attach a table without always having to create an attachment table, this example is a problem for me apart from the names.
The "target" and "self" in the conditions array would refer to the table in question.
In the case of OneToManyEntity, the query builder would substitute the name of the storage table for "target" and the name of the OneToManyEntity table for "self".
Of course this would be useful for multiple tables, like in my case where I have about 10 tables connected to the Storage table, but I don't want to put 10 separate ids on the Storage table
Which is a big question how "mappedBy" and "inversedBy" could be used, but I guess not :(
The text was updated successfully, but these errors were encountered: