相关疑难解决方法(0)

当无法使用@orderBy注释时,根据关联的实体对Doctrine Collection进行排序

我想了解基于相关实体订购Doctrine Collection的最佳方法.在这种情况下,无法使用@orderBy注释.

我在互联网上找到了5个解决方案.

1)向AbstractEntity添加方法(根据Ian Belter /sf/answers/1552846921/)

/**
 * This method will change the order of elements within a Collection based on the given method.
 * It preserves array keys to avoid any direct access issues but will order the elements
 * within the array so that iteration will be done in the requested order.
 *
 * @param string $property
 * @param array  $calledMethods
 *
 * @return $this
 * @throws \InvalidArgumentException
 */
public function orderCollection($property, $calledMethods = array())
{
    /** …
Run Code Online (Sandbox Code Playgroud)

php symfony doctrine-orm

18
推荐指数
1
解决办法
6818
查看次数

标签 统计

doctrine-orm ×1

php ×1

symfony ×1