From 3d5e5fba8a9a05417ff63f78c1d3a402fde31825 Mon Sep 17 00:00:00 2001 From: cdujeu Date: Sun, 22 Jun 2014 12:19:54 +0200 Subject: [PATCH] Put SQL update directly in PHP update code instead of SQL file --- dist/php/{5.3.1.sql => 5.3.1.php} | 60 ++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) rename dist/php/{5.3.1.sql => 5.3.1.php} (51%) diff --git a/dist/php/5.3.1.sql b/dist/php/5.3.1.php similarity index 51% rename from dist/php/5.3.1.sql rename to dist/php/5.3.1.php index 90b0866dca..79125572bf 100644 --- a/dist/php/5.3.1.sql +++ b/dist/php/5.3.1.php @@ -1,3 +1,21 @@ +getOption("SQL_DRIVER"); + if (!isSet($test["driver"])) { + $test = AJXP_Utils::cleanDibiDriverParameters($confDriver->getOption("SQL_DRIVER")); + } + if (is_array($test) && isSet($test["driver"])) { + + $parts = array_map("trim", explode("/* SEPARATOR */", $dbInst)); + $results = array(); + $errors = array(); + + require_once(AJXP_BIN_FOLDER."/dibi.compact.php"); + dibi::connect($test); + dibi::begin(); + foreach ($parts as $sqlPart) { + if(empty($sqlPart)) continue; + try { + dibi::nativeQuery($sqlPart); + echo "
$sqlPart ... OK
"; + } catch (DibiException $e) { + $errors[] = $e->getMessage(); + echo "
$sqlPart ... FAILED (".$e->getMessage().")
"; + } + } + dibi::commit(); + dibi::disconnect(); + + } else { + echo "Nothing to do for the DB"; + } + +} else { + echo "Nothing to do for the DB"; +}