Explorar o código

chequeo array index

Guillermo Espinoza %!s(int64=8) %!d(string=hai) anos
pai
achega
c77a01f0ab
Modificáronse 1 ficheiros con 6 adicións e 2 borrados
  1. 6 2
      Services/Webservice.php

+ 6 - 2
Services/Webservice.php

@@ -33,7 +33,9 @@ class Webservice
         $choices = array();
         $results = $this->getArray($webservice, $params);
         foreach ($results as $row) {
-            $choices[$row['name']] = $row['id'];
+            if (isset($row['name']) && isset($row['id'])) {
+                $choices[$row['name']] = $row['id'];
+            }
         }
 
         return $choices;
@@ -138,7 +140,9 @@ class Webservice
             'id' => $id
         ));
         
-        return isset($result[0]) ? "{$result[0]['id']} - {$result[0]['name']}" : $id;
+        return isset($result[0]) && isset($result[0]['id']) && isset($result[0]['name']) 
+                ? "{$result[0]['id']} - {$result[0]['name']}" 
+                : $id;
     }
 
     /**