Browse Source

no se envian las consultas SQL derecho a la bsae de datos

Luciano Andrade 7 years ago
parent
commit
c5260fa995
1 changed files with 6 additions and 28 deletions
  1. 6 28
      Migrations/MigrationsBase.php

+ 6 - 28
Migrations/MigrationsBase.php

@@ -216,15 +216,17 @@ class MigrationsBase extends AbstractMigration implements ContainerAwareInterfac
             $value = $this->replaceImportsValue($dir, $value);
 
             // lo hago de esta forma para que se ejecuten de acuerdo a como se escribe el yaml.
+            $this->setLine(0);
             foreach ($value as $key => $val) {
-                $this->setLine(0);
                 if (strtoupper($key) === MigrationsBase::INSERT) {
                     $this->createInserts($value[MigrationsBase::INSERT]);
                 } else if (strtoupper($key) === MigrationsBase::UPDATE) {
                     $this->createUpdates($value[MigrationsBase::UPDATE]);
                 } else if (strtoupper($key) === MigrationsBase::DELETE) {
                     $this->createDeletes($value[MigrationsBase::DELETE]);
-                }
+		}else{
+			die("Valor no esperado");
+		}
             }
         }
     }
@@ -466,10 +468,8 @@ class MigrationsBase extends AbstractMigration implements ContainerAwareInterfac
             $this->connection->beginTransaction();
             try {
                 $this->interpretYaml($dir, $file);
-                if (count($this->getErrorLineExecution()) > 0
-                ) {
+                if (count($this->getErrorLineExecution()) > 0) {
                     //se produjeron errores
-                    $this->connection->rollBack();
                     echo "\n\t\tSe produjeron errores de sql.\n";
                 } else {
                     $this->connection->commit();
@@ -493,29 +493,7 @@ class MigrationsBase extends AbstractMigration implements ContainerAwareInterfac
      */
     public function executeSQL($sql, $type, $arrayPrepare = null)
     {
-        $stmt = $this->connection->prepare($sql);
-        $param = "";
-        if ($arrayPrepare != null && count($arrayPrepare) > 0) {
-            foreach ($arrayPrepare as $keyPrepare => $valuePrepare) {
-                $stmt->bindValue($keyPrepare, $valuePrepare);
-                if ($this->isShowParameters()) {
-                    $param .= " [" . $keyPrepare . "]=" . $valuePrepare . "    ";
-                }
-            }
-        }
-        if ($this->isShowParameters()) {
-            if (strlen($param) > 4) {
-                $param = "\n\tParameters: " . substr($param, 0, strlen($param) - 4) . "\n";
-            }
-        }
-        try {
-            $resp = $stmt->execute();
-            $this->addLineExecution($type, ($resp ? "OK - " : "ERROR - ") . $sql .
-                $param);
-        } catch (\Throwable $ex) {
-            $this->addLineExecution($type, "????? - " . $sql . $param);
-            $this->addErrorLineExecution($type, $ex);
-        }
+	$this->addSql($sql, (array)$arrayPrepare);
 
         $this->sumLine();
     }