partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit 5df586b0f19c9e22bf521938536af58ca8942b77
parent 9dfb08c832465763ca0d3e08d379918e0b691729
Author: Felicitus <felicitus@felicitus.org>
Date:   Wed, 11 Jul 2012 15:44:07 +0200

Check against empty values; if so, skip the query.

Diffstat:
Msrc/backend/PartKeepr/Part/PartManager.php | 8++++++++
1 file changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/backend/PartKeepr/Part/PartManager.php b/src/backend/PartKeepr/Part/PartManager.php @@ -136,6 +136,10 @@ class PartManager extends AbstractManager { * @return Array an array where the key is the part id and the value is an array of project names */ private function getProjects (array $partIds) { + if (count($partIds) == 0) { + return array(); + } + $dql2 = "SELECT pr.name, part.id FROM PartKeepr\Project\Project pr JOIN pr.parts ppart JOIN ppart.part part WHERE ppart.part IN (:partids)"; $projectQuery = PartKeepr::getEM()->createQuery($dql2); $projectQuery->setParameter("partids", $partIds); @@ -159,6 +163,10 @@ class PartManager extends AbstractManager { * @return Array an array where the key is the part id and the value is the attachment count */ private function getAttachmentCounts (array $partIds) { + if (count($partIds) == 0) { + return array(); + } + $dql = "SELECT p.id, COUNT(pa) AS cnt FROM PartKeepr\Part\PartAttachment pa JOIN pa.part p WHERE pa.part IN (:partids) GROUP BY pa.part"; $partAttachmentQuery = PartKeepr::getEM()->createQuery($dql); $partAttachmentQuery->setParameter("partids", $partIds);