From e84158192eab00fc19e58ee86368add675b1c7c2 Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Tue, 30 Oct 2012 22:02:05 +0000 Subject: fixed a bug in the SearchController --- .../Application/Controllers/SearchController.php | 33 ++++++++++++---------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/h-source/Application/Controllers/SearchController.php b/h-source/Application/Controllers/SearchController.php index e5a873c..50e8284 100644 --- a/h-source/Application/Controllers/SearchController.php +++ b/h-source/Application/Controllers/SearchController.php @@ -244,26 +244,29 @@ class SearchController extends BaseController $lspciFiltered[] = $device; } } - $whereString = "'".implode("','",$vendorIDProductIDArray)."'"; - $data['table'] = $this->m['HardwareModel']->select()->where(array('pci_id'=>"in($whereString)"))->send(); + if (count($vendorIDProductIDArray) > 0) + { + $whereString = "'".implode("','",$vendorIDProductIDArray)."'"; + $data['table'] = $this->m['HardwareModel']->select()->where(array('pci_id'=>"in($whereString)"))->send(); - $foundPciidArray = $this->m['HardwareModel'] - ->select('pci_id') - ->where(array('pci_id'=>"in($whereString)")) - ->toList('pci_id') - ->send(); + $foundPciidArray = $this->m['HardwareModel'] + ->select('pci_id') + ->where(array('pci_id'=>"in($whereString)")) + ->toList('pci_id') + ->send(); - $notFoundDevices = array(); - - foreach ($lspciFiltered as $device) - { - if (!in_array($device['vendorId'].":".$device['deviceId'],$foundPciidArray)) + $notFoundDevices = array(); + + foreach ($lspciFiltered as $device) { - $notFoundDevices[] = $device; + if (!in_array($device['vendorId'].":".$device['deviceId'],$foundPciidArray)) + { + $notFoundDevices[] = $device; + } } - } - $data['notFoundDevices'] = $notFoundDevices; + $data['notFoundDevices'] = $notFoundDevices; + } } $this->append($data); -- cgit v1.2.3