|
@@ -216,15 +216,17 @@ class MigrationsBase extends AbstractMigration implements ContainerAwareInterfac
|
|
$value = $this->replaceImportsValue($dir, $value);
|
|
$value = $this->replaceImportsValue($dir, $value);
|
|
|
|
|
|
// lo hago de esta forma para que se ejecuten de acuerdo a como se escribe el yaml.
|
|
// 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) {
|
|
foreach ($value as $key => $val) {
|
|
- $this->setLine(0);
|
|
|
|
if (strtoupper($key) === MigrationsBase::INSERT) {
|
|
if (strtoupper($key) === MigrationsBase::INSERT) {
|
|
$this->createInserts($value[MigrationsBase::INSERT]);
|
|
$this->createInserts($value[MigrationsBase::INSERT]);
|
|
} else if (strtoupper($key) === MigrationsBase::UPDATE) {
|
|
} else if (strtoupper($key) === MigrationsBase::UPDATE) {
|
|
$this->createUpdates($value[MigrationsBase::UPDATE]);
|
|
$this->createUpdates($value[MigrationsBase::UPDATE]);
|
|
} else if (strtoupper($key) === MigrationsBase::DELETE) {
|
|
} else if (strtoupper($key) === MigrationsBase::DELETE) {
|
|
$this->createDeletes($value[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();
|
|
$this->connection->beginTransaction();
|
|
try {
|
|
try {
|
|
$this->interpretYaml($dir, $file);
|
|
$this->interpretYaml($dir, $file);
|
|
- if (count($this->getErrorLineExecution()) > 0
|
|
|
|
- ) {
|
|
|
|
|
|
+ if (count($this->getErrorLineExecution()) > 0) {
|
|
//se produjeron errores
|
|
//se produjeron errores
|
|
- $this->connection->rollBack();
|
|
|
|
echo "\n\t\tSe produjeron errores de sql.\n";
|
|
echo "\n\t\tSe produjeron errores de sql.\n";
|
|
} else {
|
|
} else {
|
|
$this->connection->commit();
|
|
$this->connection->commit();
|
|
@@ -493,29 +493,7 @@ class MigrationsBase extends AbstractMigration implements ContainerAwareInterfac
|
|
*/
|
|
*/
|
|
public function executeSQL($sql, $type, $arrayPrepare = null)
|
|
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();
|
|
$this->sumLine();
|
|
}
|
|
}
|