Skip to content
Snippets Groups Projects
Commit 0447bbe9 authored by llaffont's avatar llaffont
Browse files

Cosmogramme: possibilité d'avoir des patchs type "CREATE FUNCTION"

parent 1949d823
Branches
Tags
No related merge requests found
......@@ -54,27 +54,39 @@ if($_REQUEST["action"]=="LANCER")
print('<h3>Execution patch n° '.$num_patch.'</h3>');
$num_instruction=0;
$data=file($script);
foreach($data as $ligne)
$instructions = [];
$contents = implode(" ", $data);
if (false !== strpos($contents, 'CREATE FUNCTION'))
$instructions[] = $contents;
else {
$instruction = '';
foreach($data as $ligne)
{
$ligne=trim($ligne);
if(!$ligne or substr($ligne,0,2)=="--") continue;
$instruction.=$ligne.' ';
if(substr($ligne,-1)!=";") {
continue;
}
$instructions[]=$instruction;
$instruction = '';
}
}
foreach($instructions as $instruction)
{
$ligne=trim($ligne);
if(!$ligne or substr($ligne,0,2)=="--") continue;
print($ligne.BR);
print($instruction.BR);
flush();
// Concatener la ligne d'instruction
if(substr($ligne,-1)!=";")
{
$instruction.=$ligne;
continue;
}
$instruction.=$ligne;
// Executer
$num_instruction++;
if($_REQUEST["reprise"] > 0 and $_REQUEST["reprise"] >= $num_instruction){$instruction=""; continue;}
if($_REQUEST["reprise"] > 0 and $_REQUEST["reprise"] >= $num_instruction){continue;}
try
{
$sql->execute($instruction);
$instruction="";
}
catch(Exception $e)
{
......
DELIMITER //
CREATE FUNCTION clean_spaces(str VARCHAR(255)) RETURNS VARCHAR(255) DETERMINISTIC
BEGIN
while instr(str, ' ') > 0 do
......@@ -6,5 +5,4 @@ BEGIN
end while;
return trim(str);
END
//
DELIMITER ;
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment