Ordering by MySQL FIELD Function in Doctrine 2
Doctrine 2 does not natively support the MySQL FIELD function out of the box.要使用它,您可以利用扩展名提供的自定义字符串函数。
$ doctrineconfig = $ this-> em-> em-> getConfiguration(); $doctrineConfig->addCustomStringFunction('FIELD', 'DoctrineExtensions\Query\Mysql\Field');Usage:
The FIELD function can be used in SELECT, WHERE, and BETWEEN clauses.虽然不能按顺序直接使用,但是解决方案涉及在选择子句中添加其他字段,并通过该字段订购:通过指定选择在选择子句中的隐藏,您可以避免在结果行中显示附加字段。这使您可以使用学说2.2在In Expression中有效订购值。
免责声明: 提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发到邮箱:[email protected] 我们会第一时间内为您处理。
Copyright© 2022 湘ICP备2022001581号-3