I need to create a database query on a table whose name is order and can not be changed. I made the following query:
$query = $entityManager->createQuery("SELECT sum(o.orderPrice)
FROM \App\Entity\Order o
WHERE o.orderEventId = ?1
o.orderDate <= ?2
o.orderDate >= ?3")
->setParameters(array(
1 => $event,
2 => ' LAST_DAY(CURDATE()) ',
3 => ' DATE_SUB(LAST_DAY(NOW()), INTERVAL DAY(LAST_DAY(NOW()))-1 DAY)'
)
);
$dados['qtd_resultado'] = $query->getResult();
The namespace \ App \ Entity \ Order indicated in FROM points to the following Entity in doctrine:
namespace App\Entity;
use Doctrine \ ORM \ Mapping \ Entity;
/**
* @Entity
* @Table(name="order")
*/
class Order
{
}
The problem occurs in FROM because the word ORDER is reserved, so at the time of mounting the query the system has a syntax error. What is the correct way to enter the table name?