fix limit/sort bug for has many elements

This commit is contained in:
Dennis Eichhorn 2022-03-17 18:30:11 +01:00
parent 4cb31cc3ed
commit b034c617fd
2 changed files with 7 additions and 5 deletions

View File

@ -285,7 +285,8 @@ abstract class DataMapperAbstract
if (isset($this->sort[$member])) { if (isset($this->sort[$member])) {
foreach ($this->sort[$member] as $sort) { foreach ($this->sort[$member] as $sort) {
if ($sort['child'] === '') { // member = child element in this case
if ($member === '') {
continue; continue;
} }
@ -305,7 +306,8 @@ abstract class DataMapperAbstract
if (isset($this->limit[$member])) { if (isset($this->limit[$member])) {
foreach ($this->limit[$member] as $limit) { foreach ($this->limit[$member] as $limit) {
if ($limit['child'] === '') { // member = child element in this case
if ($member === '') {
continue; continue;
} }

View File

@ -442,7 +442,7 @@ final class ReadMapper extends DataMapperAbstract
continue; continue;
} }
foreach ($data as $index => $with) { foreach ($data as $with) {
if ($with['child'] !== '') { if ($with['child'] !== '') {
continue; continue;
} }
@ -485,7 +485,7 @@ final class ReadMapper extends DataMapperAbstract
// handle sort, the column name order is very important. Therefore it cannot be done in the foreach loop above! // handle sort, the column name order is very important. Therefore it cannot be done in the foreach loop above!
foreach ($this->sort as $member => $data) { foreach ($this->sort as $member => $data) {
foreach ($data as $index => $sort) { foreach ($data as $sort) {
if (($column = $this->mapper::getColumnByMember($member)) === null if (($column = $this->mapper::getColumnByMember($member)) === null
|| ($sort['child'] !== '') || ($sort['child'] !== '')
) { ) {
@ -504,7 +504,7 @@ final class ReadMapper extends DataMapperAbstract
continue; continue;
} }
foreach ($data as $index => $limit) { foreach ($data as $limit) {
if ($limit['child'] === '') { if ($limit['child'] === '') {
$query->limit($limit['limit']); $query->limit($limit['limit']);