Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
sortListQuery example
$em
=
$this
->
getEntityManager
(
)
;
$builder
=
$em
->
createQueryBuilder
(
)
->
select
(
[
'orders.id'
]
)
->
from
(
Order::
class
, 'orders'
)
->
leftJoin
(
'orders.attribute', 'attribute'
)
->
andWhere
(
'orders.number IS NOT NULL'
)
->
andWhere
(
'orders.status != :cancelStatus'
)
->
setParameter
(
':cancelStatus', -1
)
;
$builder
=
$this
->
filterListQuery
(
$builder
,
$filters
)
;
$builder
=
$this
->
sortListQuery
(
$builder
,
$sortings
)
;
if
(
$offset
!== null
)
{
$builder
->
setFirstResult
(
$offset
)
;
}
if
(
$limit
!== null
)
{
$builder
->
setMaxResults
(
$limit
)
;
}
/** @var Query<array{id: int}> $query */
$query
=
$builder
->
getQuery
(
)
;
$query
->
setHydrationMode
(
AbstractQuery::HYDRATE_ARRAY
)
;
$paginator
=
$em
->
createPaginator
(
$query
)
;