mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-24 02:38:50 +02:00
Added a field extension for SQLite and let the database sort the elements by the given ID order directly
This commit is contained in:
parent
1ec4266f96
commit
a4d411656b
4 changed files with 46 additions and 11 deletions
|
@ -56,13 +56,14 @@ class AttachmentContainingDBElementRepository extends NamedDBElementRepository
|
|||
$qb = $this->createQueryBuilder('element');
|
||||
$q = $qb->select('element')
|
||||
->where('element.id IN (?1)')
|
||||
//Order the results in the same order as the IDs in the input array (mysql supports this native, for SQLite we emulate it)
|
||||
->orderBy('FIELD(element.id, ?1)')
|
||||
->setParameter(1, $ids)
|
||||
->getQuery();
|
||||
|
||||
$q->setFetchMode($this->getEntityName(), 'master_picture_attachment', ClassMetadataInfo::FETCH_EAGER);
|
||||
|
||||
$result = $q->getResult();
|
||||
$this->sortResultArrayByIDArray($result, $ids);
|
||||
|
||||
//Cache the result
|
||||
$this->elementsAndPreviewAttachmentCache[$cache_key] = $result;
|
||||
|
|
|
@ -113,13 +113,12 @@ class DBElementRepository extends EntityRepository
|
|||
$q = $qb->select('element')
|
||||
->where('element.id IN (?1)')
|
||||
->setParameter(1, $ids)
|
||||
//Order the results in the same order as the IDs in the input array (mysql supports this native, for SQLite we emulate it)
|
||||
->orderBy('FIELD(element.id, ?1)')
|
||||
->getQuery();
|
||||
|
||||
$result = $q->getResult();
|
||||
|
||||
//Sort the result so that the elements are in the same order as the input array
|
||||
$this->sortResultArrayByIDArray($result, $ids);
|
||||
|
||||
//Cache the result
|
||||
$this->find_elements_by_id_cache[$cache_key] = $result;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue