[DB] Allow DQL queries with table name rather than entity

This commit is contained in:
Hugo Sales 2021-04-15 22:34:55 +00:00
parent 0d01f1d060
commit 7284c833a6
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0

View File

@ -39,6 +39,7 @@ use Doctrine\Common\Collections\ExpressionBuilder;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query;
use Doctrine\ORM\Query\ResultSetMappingBuilder;
use Functional as F;
abstract class DB
{
@ -64,6 +65,7 @@ abstract class DB
*/
public static function dql(string $query, array $params = [])
{
$query = preg_replace(F\map(self::$table_map, function ($_, $s) { return "/\\b{$s}\\b/"; }), self::$table_map, $query);
$q = new Query(self::$em);
$q->setDQL($query);
foreach ($params as $k => $v) {