浏览代码

Se chequea si existe la tabla kea.hosts

Espinoza Guillermo 6 年之前
父节点
当前提交
281e736823
共有 1 个文件被更改,包括 12 次插入0 次删除
  1. 12 0
      src/HostBundle/EventListener/KEAHostReservationSubscriber.php

+ 12 - 0
src/HostBundle/EventListener/KEAHostReservationSubscriber.php

@@ -68,6 +68,18 @@ class KEAHostReservationSubscriber implements EventSubscriber
     {
         $entity = $args->getEntity();
         if ($entity instanceof Host) {
+            $query = "SELECT COUNT(*) AS `exists`
+                    FROM information_schema.tables 
+                    WHERE table_schema = 'kea' 
+                    AND table_name = 'hosts';";
+            
+            $databaseConnection = $this->serviceContainer->get('database_connection');
+            $stmt = $databaseConnection->prepare($query);
+            $stmt->execute();
+            $tableExists = $stmt->fetchAll();
+            if (!isset($tableExists[0]['exists']) || $tableExists[0]['exists'] == '0') {
+                return;
+            }
             
             if ($entity->getFixedAddress() && $remove == false) {
                 $query = "