在我从Doctrine 2.3.6升级到Doctrine 2.5.0之后,我的脚本停止工作。
我想在连接表上使用分页执行查询。我有两个实体:Program
和ProgramVersion
由Program::versions
字段加入。
这是查询:
$query = $em->createQuery('
SELECT m, v
FROM Entity\Program m
LEFT JOIN m.versions v
WITH m.version = v.version
WHERE m.deletedDate IS NULL
ORDER BY m.type asc');
然后我将查询传递给Paginator
$pResult = new \Doctrine\ORM\Tools\Pagination\Paginator($query, true);
在我执行$pResult->getIterator()
的阶段,我收到以下错误消息:
An exception occurred while executing '
SELECT DISTINCT id_0
FROM (
SELECT e0_.id AS id_0, e1_.id AS id_27 /* removed a lot of fields here */ FROM entity_program e0_
LEFT JOIN entity_program_version e1_ ON e0_.id = e1_.master_id AND (e0_.version = e1_.version)
WHERE e0_.deleted_date IS NULL
) dctrn_result ORDER BY e0_.type_id ASC':
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'e0_.type_id' in 'order clause'
显然SQL错了。 ORDER BY
子句位于主SELECT
之外,它包含不存在的字段。
有人可以帮我解决这个问题吗?